Sha256: 91075dee9c9f13c0ef140edc708430595585cff04eca99d9d7f633da7603c2a5

Contents?: true

Size: 1009 Bytes

Versions: 1

Compression:

Stored size: 1009 Bytes

Contents

module Jekyll
  module Zettel
    # Generate tags.json from page front matter
    class Zettelkasten < Jekyll::Generator
      include Zettel

      priority :low

      SLUG_FORMAT = %r{zettel/(?<uuid>.*)/index.(?<ext>html|md)}i.freeze

      attr_reader :site

      def generate(site)
        @site = site
        @site.data['zettelkasten'] = {}

        site.pages.each do |page|
          next unless SLUG_FORMAT.match?(page.path.to_s)

          register_zettel(page)
        end

        write_catalog 'zettelkasten'
      end

      def register_zettel(doc)
        @site.data['zettelkasten'][doc.data['zettel']] = {
          'zettel' => doc.data['zettel'],
          'title' => doc.data['title'],
          'description' => doc.data['description'],
          'author' => doc.data['author'],
          'tags' => doc.data['tags'],
          'folgezettel' => doc.data['folgezettel'],
          'via' => doc.data['via'],
          'citekey' => doc.data['citekey']
        }
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-zettel-0.4.0 lib/jekyll/zettel/zettelkasten.rb