]>
Commit | Line | Data |
---|---|---|
89539330 BB |
1 | module Jekyll |
2 | ||
3 | class CategoryIndex < Page | |
4 | def initialize(site, base, dir, category) | |
5 | @site = site | |
6 | @base = base | |
7 | @dir = dir | |
8 | @name = 'index.html' | |
9 | ||
10 | self.process(@name) | |
11 | self.read_yaml(File.join(base, '_layouts'), 'category_index.html') | |
12 | self.data['category'] = category | |
13 | ||
14 | category_title_prefix = site.config['category_title_prefix'] || 'Category: ' | |
15 | self.data['title'] = "#{category_title_prefix}#{category}" | |
16 | self.data['description'] = "Lista de articulos categorizados #{category} en Abuguet, el blog mas guapo de videojuegos." | |
17 | end | |
18 | end | |
19 | ||
20 | class CategoryGenerator < Generator | |
21 | safe true | |
22 | ||
23 | def generate(site) | |
24 | if site.layouts.key? 'category_index' | |
25 | dir = site.config['category_dir'] || 'categories' | |
26 | site.categories.keys.each do |category| | |
27 | write_category_index(site, File.join(dir, category), category) | |
28 | end | |
29 | end | |
30 | end | |
31 | ||
32 | def write_category_index(site, dir, category) | |
33 | index = CategoryIndex.new(site, site.source, dir, category) | |
34 | index.render(site.layouts, site.site_payload) | |
35 | index.write(site.dest) | |
36 | site.pages << index | |
37 | end | |
38 | end | |
39 | ||
40 | end |