Class: JekyllThemeGuidesMbland::Generator

Inherits:
Jekyll::Generator
  • Object
show all
Defined in:
lib/jekyll-theme-guides-mbland/generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generate_working_url(doc) ⇒ Object

Calling the `url` method on a Jekyll::Page or Jekyll::Document will render the returned value immutable from that point. Here we generate a separate URL object that we use to calculate `data` prior to the first call to `url`. This enables `NamespaceFlattener.flatten_url_namespace` to update the URL as a final step, after `Breadcrumbs.generate` has finished its processing.


24
25
26
27
28
29
30
31
# File 'lib/jekyll-theme-guides-mbland/generator.rb', line 24

def self.generate_working_url(doc)
  t = doc.respond_to?(:url_template) ? doc.url_template : doc.template
  doc.data[:working_url] = Jekyll::URL.new(
    template:     t,
    placeholders: doc.url_placeholders,
    permalink:    doc.permalink
  ).to_s
end

Instance Method Details

#generate(site) ⇒ Object


9
10
11
12
13
14
15
16
# File 'lib/jekyll-theme-guides-mbland/generator.rb', line 9

def generate(site)
  GeneratedPages.generate_pages_from_navigation_data(site)
  pages = site.collections['pages']
  docs = (pages.nil? ? [] : pages.docs) + site.pages
  docs.each { |doc| Generator.generate_working_url(doc) }
  Breadcrumbs.generate(site, docs)
  NamespaceFlattener.flatten_url_namespace(site, docs)
end