adding tags and categories

This commit is contained in:
Holger Reinhardt 2016-01-04 13:09:07 +01:00
parent 1c960f4aa8
commit a488bb0f59
16 changed files with 182 additions and 8 deletions
_layouts

View file

@ -2,6 +2,8 @@
layout: default
---
{% assign post = page %}
<article class="post">
<h1>{{page.title}}</h1>
@ -9,6 +11,38 @@ layout: default
<span>{{page.date | date: "%B %d, %Y" }}</span>
/
<span>by {{page.author}}</span>
{% if post.category %}
{% for site_category in site.data.categories %}
{% if site_category.slug == post.category %}
{% assign category = site_category %}
{% endif %}
{% endfor %}
{% if category %}
{% capture category_content %} in <span class="label" style="background-color:{{ category.color }}"><a href="/blog/category/{{ category.slug }}/">{{ category.name }}</a></span>{% endcapture %}
{% endif %}
{% else %}
{% assign category_content = '' %}
{% endif %}
{% if post.tags.size > 0 %}
{% capture tags_content %} with {% if post.tags.size == 1 %}<i class="fa fa-tag"></i>{% else %}<i class="fa fa-tags"></i>{% endif %}: {% endcapture %}
{% for post_tag in post.tags %}
{% for data_tag in site.data.tags %}
{% if data_tag.slug == post_tag %}
{% assign tag = data_tag %}
{% endif %}
{% endfor %}
{% if tag %}
{% capture tags_content_temp %}{{ tags_content }}<a href="/blog/tag/{{ tag.slug }}/">{{ tag.name }}</a>{% if forloop.last == false %}, {% endif %}{% endcapture %}
{% assign tags_content = tags_content_temp %}
{% endif %}
{% endfor %}
{% else %}
{% assign tags_content = '' %}
{% endif %}
<p id="post-meta">Posted {{ category_content }}{{ tags_content }}</p>
</p>
<hr/>