Sha256: 5bcf7f81b199f504d121de95a3a03517ad2b545309883174c3f6f011f682d5b2

Contents?: true

Size: 692 Bytes

Versions: 21

Compression:

Stored size: 692 Bytes

Contents

module Jekyll
  module Zettel
    # Enrich page front matter with timeline data
    class Timeline < Jekyll::Generator

      attr_reader :site

      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

      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

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
jekyll-zettel-0.7.2 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.7.1 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.7.0 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.10 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.9 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.8 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.7 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.5 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.4 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.3 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.2 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.1 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.6.0 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.5.3 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.5.2 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.5.0 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.4.3 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.4.2 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.4.1 lib/jekyll/zettel/timeline.rb
jekyll-zettel-0.4.0 lib/jekyll/zettel/timeline.rb