Class: Jekyll::GeneratorSingleSource::NavConfig::PathRewriter
- Inherits:
-
Object
- Object
- Jekyll::GeneratorSingleSource::NavConfig::PathRewriter
- Defined in:
- lib/jekyll/generator-single-source/nav_config/path_rewriter.rb
Instance Method Summary collapse
-
#initialize(new_path:, entry:) ⇒ PathRewriter
constructor
A new instance of PathRewriter.
- #rewrite! ⇒ Object
- #rewrite_rec(entry) ⇒ Object
Constructor Details
#initialize(new_path:, entry:) ⇒ PathRewriter
Returns a new instance of PathRewriter.
7 8 9 10 |
# File 'lib/jekyll/generator-single-source/nav_config/path_rewriter.rb', line 7 def initialize(new_path:, entry:) @new_path = new_path @entry = entry end |
Instance Method Details
#rewrite! ⇒ Object
32 33 34 |
# File 'lib/jekyll/generator-single-source/nav_config/path_rewriter.rb', line 32 def rewrite! rewrite_rec(@entry) end |
#rewrite_rec(entry) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jekyll/generator-single-source/nav_config/path_rewriter.rb', line 12 def rewrite_rec(entry) entry['items'].map do |v| next if v['absolute_url'] if v.has_key?('src') original = v['src'] v['src'] = File.join(@new_path, original) Jekyll.logger.debug("rewrote #{original} to #{v['src']}") elsif v.has_key?('url') original = v['url'] parts = v['url'].split('#', 2) unless parts[1] v['url'] = original v['src'] = File.join(@new_path, original) Jekyll.logger.debug("rewrote #{original} to #{v['src']}") end end rewrite_rec(v) if v.has_key?('items') end end |