Class: Jekyll::FridgePageGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll-fridge/fridge_page.rb

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/jekyll-fridge/fridge_page.rb', line 39

def generate(site)
  return if site.config['fridge_collections'].nil?

  client = site.config['fridge']
  site.config['fridge_collections'].each do |type, options|
    options = {
      'type' => type,
      'query' => "content?type=#{type}",
      'path' => type,
      'layout' => "#{type}.html"
    }.merge(options || {})

    client.get(options['query']).each do |document|
      slug = document.slug == 'index' ? '' : document.slug
      site.pages << FridgePage.new(site, site.source, File.join(options['path'], slug), document, options)
    end
  end
end