Class: Jekyll::Zettel::Zettelkasten
- Inherits:
-
Generator
- Object
- Generator
- Jekyll::Zettel::Zettelkasten
- Includes:
- Jekyll::Zettel
- Defined in:
- lib/jekyll/zettel/zettelkasten.rb
Overview
Generate tags.json from page front matter
Constant Summary collapse
- SLUG_FORMAT =
%r{zettel/(?<uuid>.*)/index.(?<ext>html|md)}i.freeze
Constants included from Jekyll::Zettel
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
Methods included from Jekyll::Zettel
#args_empty?, #create_dir_defensively, #create_page, #create_slug, #evaluate_template, #write_catalog
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
11 12 13 |
# File 'lib/jekyll/zettel/zettelkasten.rb', line 11 def site @site end |
Instance Method Details
#generate(site) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jekyll/zettel/zettelkasten.rb', line 13 def generate(site) @site = site @site.data['zettelkasten'] = {} @site.data['tag2zettel'] = {} site.pages.each do |page| next unless SLUG_FORMAT.match?(page.path.to_s) register_zettel(page) (page) end write_catalog 'zettelkasten' write_catalog 'tag2zettel' end |
#register_tags(doc) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/jekyll/zettel/zettelkasten.rb', line 42 def (doc) return unless doc.data.key?('tags') doc.data['tags'].each { |tag| @site.data['tag2zettel'][tag] = [] unless @site.data['tag2zettel'].key?(tag) @site.data['tag2zettel'][tag] << doc.data['id'] } end |
#register_zettel(doc) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/jekyll/zettel/zettelkasten.rb', line 29 def register_zettel(doc) @site.data['zettelkasten'][doc.data['id']] = { 'zettel' => doc.data['id'], '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 |