Skip to content

Commit

Permalink
✨ Add tag pages
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffb committed Jan 5, 2024
1 parent 943416b commit 078427c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
3 changes: 2 additions & 1 deletion htdocs/_data/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
{ "label": "Posts", "url": "/blog/" },
{ "label": "About", "url": "/about/" },
{ "label": "Subscribe", "url": "/subscribe/" }
]
],
"hiddenTags": ["post", "feature"]
}
3 changes: 1 addition & 2 deletions htdocs/_includes/macros.njk
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% macro postList(collectionKey, count) %}
{% set posts = collections[collectionKey].slice().reverse() %}
<ul>
{% for post in posts %}
{% for post in collections[collectionKey] | reverse %}
{% if count === undefined or loop.index <= count %}
<li><a href="{{ post.url }}">{{ post.data.title }}</a></li>
{% endif %}
Expand Down
9 changes: 9 additions & 0 deletions htdocs/_includes/post.njk
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ og_type: article

{% block page_main %}
<h1>{{ title }}</h1>
{% if tags.length > 0 %}
<p>
{% for tag in tags | sort %}
{% if site.hiddenTags.includes(tag) === false %}
<a href="/tags/{{ tag }}/">#{{ tag }}</a>
{% endif %}
{% endfor %}
</p>
{% endif %}
<time>{{ date | format_date }}</time>
{{ super() }}
{% endblock %}
5 changes: 4 additions & 1 deletion htdocs/blog/2024-roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ date: 2024-1-3 12:00:00
layout: post.njk
tags:
- post
- gamedev
- travel
- 7DRL
---

Happy New Year!
Expand Down Expand Up @@ -39,7 +42,7 @@ I intend to post a summary each day, like we did for our [New Zealand trip in 20

I would like to post here more often and once a month seems like an easy bar to hit. One post per month is the floor; hopefully I can post more than that.

Expect similar content to [my existing posts](/blog/), e.g. [gamedev articles](/blog/rain-effect-html5-canvas/), [development logs](/blog/gloomstone-devlog-1/), [travel](/blog/new-zealand-2014-day-1/), and sometimes [art](/blog/shining-force-portraits/).
Expect similar content to [my existing posts](/blog/), e.g. [gamedev articles](/tags/gamedev/), [development logs](/tags/devlog/), [travel](/tags/travel/), and sometimes [art](/tags/art/).

This post takes care of January, at least!

Expand Down
18 changes: 18 additions & 0 deletions htdocs/tags.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
layout: base.njk
pagination:
data: collections
size: 1
alias: tag
filter:
- post
- feature
permalink: /tags/{{ tag }}/
eleventyComputed:
title: "Posts tagged #{{ tag }}"
---
{% from "macros.njk" import postList with context %}

<h1>Posts tagged #{{ tag }}</h1>

{{ postList(tag) }}

0 comments on commit 078427c

Please sign in to comment.