Class: Jekyll::WikiLinks::Generator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll-wikilinks/plugins/generator.rb

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jekyll-wikilinks/plugins/generator.rb', line 15

def generate(site)
  return if $wiki_conf.disabled?

  @site ||= site
  @context ||= Jekyll::WikiLinks::Context.new(site)

  # setup helper classes
  @parser = Parser.new(@site)
  @site.link_index = LinkIndex.new(@site)

  @site.doc_mngr.all.each do |doc|
    filename = File.basename(doc.basename, File.extname(doc.basename))
    @parser.parse(filename, doc.content)
    @site.link_index.populate(doc, @parser.wikilink_blocks, @parser.wikilink_inlines)
  end
  # wait until all docs are processed before assigning backward facing metadata,
  # this ensures all attributed/backlinks are collected for assignment
  @site.doc_mngr.all.each do |doc|
    # populate frontmatter metadata from (wiki)link index
    @site.link_index.(doc)
  end
end