Class: Jekyll::GeneratorSingleSource::Generator

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

Instance Method Summary collapse

Instance Method Details

#build_i18n_file(site:, file:, config:) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/jekyll/generator-single-source/generator.rb', line 22

def build_i18n_file(site:, file:, config:)
  I18nFile.new(
    file: Pathname.new(file).basename.to_s,
    src_path: config.docs_nav_folder.gsub("#{site.source}/", ''),
    locale: site.config['locale'],
    site:
  )
end

#generate(site) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll/generator-single-source/generator.rb', line 10

def generate(site)
  config = GeneratorConfig.new(site)

  Dir.glob(File.join(config.docs_nav_folder, 'docs_nav_*.yml')).each do |f|
    i18n_file = build_i18n_file(site:, file: f, config:)

    # Use docs_nav_files in english as source of truth
    # to generate the pages
    DocNavConfig.new(i18n_file:, site:).generate_pages
  end
end