Skip to content

Commit

Permalink
feat: add tags for each post
Browse files Browse the repository at this point in the history
  • Loading branch information
sayanee committed Dec 23, 2023
1 parent ec8855a commit 2d19cbd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ description: Collection of highlights from the books I have read over the years
url: "https://books.sayan.ee"
markdown: kramdown
permalink: /:title
tag_mapping:
1: "self-help"
2: "spirituality"
3: "fiction"
4: "biography"
9 changes: 9 additions & 0 deletions _includes/tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% assign tag_mapping = site.tag_mapping %}
{% if post.tags %}
{% for tag_number in post.tags %}
{% assign tag_number = tag_number | plus: 1 | strip %}
{% if tag_mapping[tag_number] %}
<span class="tag is-info">{{ tag_mapping[tag_number] }}</span>
{% endif %}
{% endfor %}
{% endif %}
14 changes: 14 additions & 0 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ <h1 class="title my-6">{{ page.title }}</h1>
{% endif %}
</div>
</div>

{% assign tag_mapping = site.tag_mapping %}
{% if page.tags %}
{% for tag_number in page.tags %}
{% assign tag_number = tag_number | plus: 1 | strip %}
{% if tag_mapping[tag_number] %}
<div class="control">
<div class="tags">
<span class="tag is-medium is-info">{{ tag_mapping[tag_number] }}</span>
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
</div>

{{ content }}
Expand Down
1 change: 1 addition & 0 deletions _posts/2021-11-10-siddhartha.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
layout: post
title: "Siddhartha"
authors: Hermann Hesse
tags: [2,3]
---

Awakening
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<tr>
<td>
<a href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
{% include tags.html %}

<p class="is-hidden-tablet">
{% include info.html %}
</p>
Expand Down

0 comments on commit 2d19cbd

Please sign in to comment.