Class: Jekyll::Zettel::Timeline
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::Zettel::Timeline
- Defined in:
- lib/jekyll/zettel/timeline.rb
Overview
Enrich page front matter with timeline data
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
6 7 8 |
# File 'lib/jekyll/zettel/timeline.rb', line 6 def site @site end |
Instance Method Details
#generate(site) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/jekyll/zettel/timeline.rb', line 8 def generate(site) @site = site site.pages.each do |page| next unless page.path.to_s.end_with?('index.html') || page.path.to_s.end_with?('index.md') tie_timeline(page) end end |
#tie_timeline(doc) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/jekyll/zettel/timeline.rb', line 18 def tie_timeline(doc) dir = File.dirname(doc.path) file = @site.in_source_dir(dir, 'timeline.json') return unless File.exist?(file) doc.data['timeline'] = SafeYAML.load_file(file) doc.data['timeline']['src'] = "#{doc.url}timeline.json" end |