Class: JekyllReadmeIndex::Generator

Inherits:
Jekyll::Generator
  • Object
show all
Defined in:
lib/jekyll-readme-index/generator.rb

Constant Summary collapse

INDEX_REGEX =
%r!$|index\.(html?|xhtml|xml)$!i.freeze
CONFIG_KEY =
"readme_index"
ENABLED_KEY =
"enabled"
CLEANUP_KEY =
"remove_originals"
FRONTMATTER_KEY =
"with_frontmatter"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Generator

Returns a new instance of Generator.



17
18
19
# File 'lib/jekyll-readme-index/generator.rb', line 17

def initialize(site)
  @site = site
end

Instance Attribute Details

#siteObject

Returns the value of attribute site.



7
8
9
# File 'lib/jekyll-readme-index/generator.rb', line 7

def site
  @site
end

Instance Method Details

#generate(site) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll-readme-index/generator.rb', line 21

def generate(site)
  @site = site
  return if disabled?

  readmes.each do |readme|
    next unless should_be_index?(readme)

    site.pages << readme.to_page
    site.static_files.delete(readme) if cleanup?
  end

  if with_frontmatter?
    readmes_with_frontmatter.each do |readme|
      next unless should_be_index?(readme)

      readme.update_permalink
    end
  end
end