Class: RageRender::FrontpageGenerator

Inherits:
Jekyll::Generator
  • Object
show all
Defined in:
lib/ragerender/jekyll.rb

Overview

The index for the site can be set by configuration

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/ragerender/jekyll.rb', line 92

def generate site
  comics = site.collections['comics']
  frontpage = site.config.fetch('frontpage', 'latest')
  index = case frontpage
  when 'latest'
    collection = site.collections['comics'].docs
    comics.docs.last
  when 'first'
    collection = site.collections['comics'].docs
    comics.docs.first
  when 'chapter'
    collection = site.collections['comics'].docs
    chapter = comics.docs.last.data['chapter']
    comics.docs.detect {|c| c.data['chapter'] == chapter }
  when 'blog', 'archive', 'overview'
    collection = site.pages
    site.pages.detect {|p| p.data["permalink"] == "/#{frontpage}/index.html" }
  else
    collection = site.pages
    site.pages.detect {|p| p.data["slug"] == frontpage }
  end.dup
  if index.nil?
    collection = site.pages
    index = site.pages.detect {|p| p.data['title'] == 'Comic not found' }.dup
  end
  index.instance_variable_set(:"@data", index.data.dup)
  index.data['permalink'] = '/index.html'
  index.data['slug'] = 'frontpage'
  collection << index
end