Skip to content

Commit

Permalink
Merge pull request #46 from harish-coeff/for-tags
Browse files Browse the repository at this point in the history
Taxonomy and tags
  • Loading branch information
not-matthias authored Mar 26, 2024
2 parents 24b339e + d216cc4 commit 756dbc2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
2 changes: 2 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ build_search_index = false
generate_feed = true
compile_sass = true
minify_html = true
taxonomies = [{ name = "tags" }]

[markdown]
highlight_code = true
Expand All @@ -22,6 +23,7 @@ menu = [
{ name = "/posts", url = "/posts", weight = 1 },
{ name = "/projects", url = "/projects", weight = 2 },
{ name = "/about", url = "/about", weight = 3 },
{ name = "/tags", url = "/tags", weight = 4 },
]

socials = [
Expand Down
17 changes: 17 additions & 0 deletions templates/macros/macros.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{% macro list_title(pages, tag_name=false) %}
{% if tag_name %}
<h1>Entries tagged - "{{ term.name }}"</h1>
{% else %}
<h1 class="page-title">All articles</h1>
{% endif %}

<ul class="posts">
{% for page in pages %}
<li class="post">
<a href="{{ page.permalink }}">{{ page.title }}</a>
<span class="meta">{{ page.date | date(format="%Y-%m-%d") }}</span>
</li>
{% endfor %}
</ul>
{% endmacro list_title %}

{% macro list_posts(pages) %}
<ul>
{%- for page in pages %}
Expand Down
13 changes: 11 additions & 2 deletions templates/taxonomy_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
{%extends "base.html"%}

{% block main_content %}
{{ post_macros::page_header(title=taxonomy.name) }}
{{ post_macros::list_terms(terms=terms) }}
<div class="tag-cloud">
<ul class="tags">
{% for term in terms %}
<li>
<a href="{{ term.permalink | safe }}">
{{ term.name }} ({{ term.pages | length }} post{{ term.pages | length | pluralize }})
</a>
</li>
{% endfor %}
</ul>
</div>
{% endblock main_content %}
19 changes: 3 additions & 16 deletions templates/taxonomy_single.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
{% extends "section.html" %}
{% extends "index.html" %}

{% block main_content %}

{% block title %}
{{ post_macros::page_header(title=term.name) }}
{% endblock title %}

{% block post_list %}
<main class="list">
{%- if paginator %}
{%- set show_pages = paginator.pages -%}
{% else %}
{%- set show_pages = term.pages -%}
{% endif -%}
{{ post_macros::list_title(pages=term.pages, tag_name=term.name) }}

{{ post_macros::list_posts(pages=show_pages) }}
</main>
{% endblock post_list %}
{% block main_content %}
{% endblock main_content %}

0 comments on commit 756dbc2

Please sign in to comment.