Skip to content

Commit

Permalink
Rename template files for categories
Browse files Browse the repository at this point in the history
  • Loading branch information
helenclx committed Sep 14, 2024
1 parent ce611c9 commit 9635a57
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 37 deletions.
22 changes: 0 additions & 22 deletions src/blog/categories-list.njk

This file was deleted.

31 changes: 16 additions & 15 deletions src/blog/categories.njk
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
---
pagination:
data: collections.categories
size: 1
alias: category
permalink: /blog/categories/{{ category | slugify }}/
layout: global/content
eleventyComputed:
title: 'Blog Post Category: "{{ category }}"'
eleventyNavigation:
key: {{ category }}
parent: Categories
title: Blog Post Categories
tags: blog pages
blogNav: Categories
eleventyNavigation:
key: Blog Categories
title: Categories
parent: Blog
order: 2
---
{% set postCount = collections.posts | filterByCategory(category) | length %}
<h2>{{ postCount }} Posts Filed Under "{{ category }}"</h2>

{% set postList = collections.posts | filterByCategory(category) | reverse %}
{% include "blog/postslist.njk" %}
<ul>
{% for category in collections.categories %}
{% set categoryUrl %}/blog/categories/{{ category | slugify }}/{% endset %}
{% set categoryPostCount = collections.posts | filterByCategory(category) | length %}
<li><a href="{{ categoryUrl }}">{{ category }}</a> ({{ categoryPostCount }} posts)</li>
{% endfor %}
</ul>

<p>See <a href="/blog/categories/">all blog post categories</a>.</p>
<p>See all blog posts in the <a href="/blog/posts/">archive</a>.</p>
20 changes: 20 additions & 0 deletions src/blog/category.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
pagination:
data: collections.categories
size: 1
alias: category
permalink: /blog/categories/{{ category | slugify }}/
layout: global/content
eleventyComputed:
title: 'Blog Post Category: "{{ category }}"'
eleventyNavigation:
key: {{ category }}
parent: Categories
---
{% set postCount = collections.posts | filterByCategory(category) | length %}
<h2>{{ postCount }} Posts Filed Under "{{ category }}"</h2>

{% set postList = collections.posts | filterByCategory(category) | reverse %}
{% include "blog/postslist.njk" %}

<p>See <a href="/blog/categories/">all blog post categories</a>.</p>

0 comments on commit 9635a57

Please sign in to comment.