Sha256: 87cbbc461dc069ba941ffb5516b2f6c4a07a9fca047ee98afec698e849ef4abd
Contents?: true
Size: 873 Bytes
Versions: 2
Compression:
Stored size: 873 Bytes
Contents
module Jekyll module Zettel # Generate tags.json from page front matter class Tags < Jekyll::Generator include Zettel SLUG_FORMAT = %r{glosse/(?<slug>.*)/index.(?<ext>html|md)}i.freeze attr_reader :site def generate(site) @site = site @site.data['tags'] = {} site.pages.each do |page| next unless SLUG_FORMAT.match?(page.path.to_s) register_tag(page) end write_catalog 'tags' end def register_tag(doc) parts = doc.path.to_s.match(SLUG_FORMAT) @site.data['tags'][parts[:slug]] = { 'slug' => parts[:slug], 'tag' => doc.data['tag'] || 'Missing @tag', 'label' => doc.data['title'] || 'Missing @title', 'description' => doc.data['description'] || 'Missing @description' } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-zettel-0.4.0 | lib/jekyll/zettel/tags.rb |
jekyll-zettel-0.3.0 | lib/jekyll/zettel/tags.rb |