Commit ac53bcf0 authored by Murukesh Mohanan's avatar Murukesh Mohanan

generate pages for tags

parent 8b13f644
Pipeline #1184 failed with stage
......@@ -26,6 +26,7 @@ pages_list:
Resources: 'resources'
Blog: 'blog'
exclude: [vendor, "Gemfile", "Gemfile.lock"]
exclude: [vendor, "Gemfile", "Gemfile.lock", "README.md", "LICENSE"]
paginate: 5
paginate_path: "/blog/page:num/"
future: true
---
title: Tag
pagestyle: tag
layout: default
---
{% assign tag = site.data.tags[page.tag] %}
<section class="tag-title">
<header>
<h1>{{ tag.name }}</h1>
</header>
<hr>
{{ tag.desc }}
</section>
{% for post in site.posts %}
{% if post.tags contains page.tag %}
<section class="post">
<header class="post-title">
<h1>
<a href="{{site.base-url}}{{ post.url }}#main">{{ post.title }}</a>
<time datetime="{{ post.date | date_to_xmlschema }}" class="post-date">
{{ post.date | date: "%B %e, %Y" }}
</time>
{% if post.tags.size > 0 %}
</h1>
<ol class="tags-list">
{% for post_tag in post.tags %}
{% assign tag = site.data.tags[post_tag] %}
{% if tag %}
<li><a class="tag" href="/blog/tag/{{ post_tag }}/">{{ tag.name }}</a></li>
{% endif %}
{% endfor %}
</ol>
{% endif %}
</header>
<hr>
{{ post.excerpt }}
</section>
{% endif %}
{% endfor %}
# Thanks to http://charliepark.org/tags-in-jekyll/
module Jekyll
class TagIndex < Page
def initialize(site, base, dir, tag)
@site = site
@base = base
@dir = dir
@name = 'index.html'
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'tag.html')
self.data['tag'] = tag
tag_title_prefix = site.config['tag_title_prefix'] || 'Posts Tagged &ldquo;'
tag_title_suffix = site.config['tag_title_suffix'] || '&rdquo;'
self.data['title'] = "#{tag_title_prefix}#{tag}#{tag_title_suffix}"
end
end
class TagGenerator < Generator
safe true
def generate(site)
if site.layouts.key? 'tag'
dir = site.config['tag_dir'] || 'blog/tag'
site.data['tags'].each do |tag, val|
write_tag_index(site, File.join(dir, tag), tag)
end
end
end
def write_tag_index(site, dir, tag)
index = TagIndex.new(site, site.source, dir, tag)
index.render(site.layouts, site.site_payload)
index.write(site.dest)
site.pages << index
end
end
end
@import 'posts.css';
section.post {
background-color: #8598a2;
color: white;
}
section.post>header>h1>a:link, section.post>header>h1>a:visited {
color: honeydew;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment