Display categories and tags in menu

master
Emil Miler 3 years ago
parent cdb2ca82ed
commit fc249504d1

@ -7,8 +7,15 @@ title = "tp.0x45.cz"
description = ""
default_language = "en"
taxonomies = [
{name = "categories"},
{name = "tags"}
]
[extra]
nav = [
{title = "Index", path = "/"},
{title = "About", path = "/about/"}
]
categories_title = "Categories"
tags_title = "Tags"

@ -3,4 +3,5 @@ title = "Lorem Ipsum"
[taxonomies]
categories = ["lorem", "ipsum"]
tags = ["lorem", "ipsum"]
+++

@ -24,6 +24,11 @@ header {
font-size: 1.5em;
}
aside span.title {
display: block;
margin: 2em 0 1em 0;
font-weight: bold;
}
aside ul {
list-style-type: none;
padding: 0;

@ -1,3 +1,4 @@
{% import "macros.html" as macros %}
<!DOCTYPE html>
<html lang="{{ config.default_language }}">
<head>
@ -19,6 +20,8 @@
<li><a href="{{ item.path }}">{{ item.title }}</a></li>
{% endfor %}
</ul>
{{ macros::list_taxonomy(title=config.extra.categories_title, kind="categories") }}
{{ macros::list_taxonomy(title=config.extra.tags_title, kind="tags") }}
</aside>
<main>
{% block content %}

@ -0,0 +1,10 @@
{% macro list_taxonomy(title, kind) %}
<span class="title">{{ title }}</span>
<ul>
{% set tags = get_taxonomy(kind=kind) %}
{% for term in tags.items %}
<li class="item"><a href="{{ term.permalink | safe }}">{{ term.name |capitalize }}</a></li>
{% endfor %}
</ul>
{% endmacro list_categories %}
Loading…
Cancel
Save