Skip to content

Commit

Permalink
Merge pull request #9 from kranurag7/tags
Browse files Browse the repository at this point in the history
Add tags and categories to the theme
  • Loading branch information
InputUsername authored Aug 22, 2024
2 parents 1262c7b + 7b78c33 commit 3769327
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 2 deletions.
5 changes: 5 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ build_search_index = false
title = "Hook"
description = "Hook is a theme for Zola"

taxonomies = [
{name = "categories"},
{name = "tags"},
]

[markdown]

# Whether to do syntax highlighting
Expand Down
1 change: 1 addition & 0 deletions content/blog/hello-world.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
+++
title = "Hello world"
date = 2021-07-29
taxonomies.categories = ["intro"]
+++

Hello world!
7 changes: 7 additions & 0 deletions content/blog/markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
title = "Markdown example"
description = "This page demonstrates how Markdown looks in the Hook theme for Zola"
date = 2021-07-30
taxonomies.tags = [
"markdown",
"syntax",
]
taxonomies.categories = [
"intro"
]
+++

This post is a markdown example.
Expand Down
4 changes: 4 additions & 0 deletions sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ body {
margin-bottom: 4em;
}

.small {
font-size: 75%;
}

h1, h2, h3, h4, h5, h6 {
line-height: 1.25;
}
Expand Down
13 changes: 11 additions & 2 deletions templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,17 @@
{% block content %}
<main>
<h1>{{ page.title }}</h1>
{% if page.date %}
<p class="secondary">{{ page.date | date(format="%-d %B, %Y") }}</p>
{% if page.date or page.taxonomies %}
<p class="secondary small">
{% if page.date %}{{ page.date | date(format="%-d %B, %Y") }}{% endif %}
{% for taxonomy_name, terms in page.taxonomies %}
- {{ taxonomy_name | capitalize }}:
{% for term_name in terms %}
{% set term = get_taxonomy_term(kind=taxonomy_name, term=term_name) %}
<a href="{{ term.permalink }}">{{ term.name }}</a>{% if not loop.last %},{% endif %}
{% endfor %}
{% endfor %}
</p>
{% endif %}
<div class="space"></div>
{{ page.content | safe }}
Expand Down
20 changes: 20 additions & 0 deletions templates/taxonomy_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "page.html" %}

{% block title %}{{ config.title }} | {{ taxonomy.name | capitalize }}{% endblock title %}

{% block content %}
<main>
<h1>{{ taxonomy.name | capitalize }}</h1>
<div>
<ul>
{% for term in terms %}
<li>
<a href="{{ term.permalink }}">{{ term.name }}</a>
{% set count = term.pages | length %}
<span class="secondary small">({{ count }} page{{ count | pluralize }})</span>
</li>
{% endfor %}
</ul>
</div>
</main>
{% endblock content %}
18 changes: 18 additions & 0 deletions templates/taxonomy_single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% extends "page.html" %}

{% block title %}{{ config.title }} | {{ term.name }}{% endblock title %}

{% block content %}
<main>
<h1>{{ taxonomy.name | capitalize }} - {{ term.name }} </h1>
<ul>
{% for page in term.pages %}
<li>
<a href="{{ page.permalink | safe }}">{{ page.title }}</a>
{% if page.date %}<span class="secondary small">({{ page.date }})</span>{% endif %}
</li>
{% endfor %}
</ul>
<p><a href="{{ get_taxonomy(kind=taxonomy.name) | get(key='permalink') }}">All {{ taxonomy.name }}</a></p>
</main>
{% endblock content %}

0 comments on commit 3769327

Please sign in to comment.