From 343e20177fa17aab0ef00b3d43f5ab73bdeace27 Mon Sep 17 00:00:00 2001 From: mat ess Date: Sat, 13 Aug 2022 00:47:49 -0400 Subject: [PATCH] Tags --- config.toml | 5 ++ content/posts/gitea-on-fly-io.md | 5 +- sass/main.scss | 18 ++++ templates/macros/macros.html | 148 +++++++++++++++++++++++++++++++ templates/taxonomy_list.html | 13 +++ templates/taxonomy_single.html | 9 ++ 6 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 templates/macros/macros.html create mode 100644 templates/taxonomy_list.html create mode 100644 templates/taxonomy_single.html diff --git a/config.toml b/config.toml index 1684482..55f1a73 100644 --- a/config.toml +++ b/config.toml @@ -9,8 +9,13 @@ generate_feed = true theme = "apollo" +taxonomies = [ + { name = "tags" }, +] + [markdown] highlight_code = true +highlight_theme = "zenburn" render_emoji = false external_links_target_blank = true external_links_no_referrer = true diff --git a/content/posts/gitea-on-fly-io.md b/content/posts/gitea-on-fly-io.md index ec4cde4..7a07a5f 100644 --- a/content/posts/gitea-on-fly-io.md +++ b/content/posts/gitea-on-fly-io.md @@ -1,6 +1,9 @@ +++ title = "diy code hosting with gitea and fly.io" -date = "2022-08-08" +date = "2022-08-07" +updated = "2022-08-08" +[taxonomies] +tags = ["git", "gitea", "fly.io"] +++ ## Setting the scene diff --git a/sass/main.scss b/sass/main.scss index 1a080c4..e5b68d6 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -138,4 +138,22 @@ code { // Page title width .page-header { max-width: 720px; +} + +// Tags +ul.tags { + margin: 0.5rem; + + li { + margin-right: 0.6rem; + display: inline-block; + + a { + margin-left: 0; + } + } +} + +.meta.tags { + float: right; } \ No newline at end of file diff --git a/templates/macros/macros.html b/templates/macros/macros.html new file mode 100644 index 0000000..c0d813c --- /dev/null +++ b/templates/macros/macros.html @@ -0,0 +1,148 @@ +{% macro list_posts(pages) %} + +{% endmacro list_posts %} + +{% macro tags(page, short=false) %} +{%- if page.taxonomies and page.taxonomies.tags %} + + {%- if short %} + :: + {%- set sep = "," -%} + {% else %} + :: tags:  + {%- set sep = " " -%} + {% endif -%} + {%- for tag in page.taxonomies.tags %} + + {%- if not loop.last %}{{ sep | safe }}{% endif -%} + {% endfor -%} + +{% endif -%} +{% endmacro tags %} + +{% macro page_header(title) %} + +{% endmacro content %} + +{% macro content(page) %} +
+
+
+ {#

{{ page.title }}

#} + {{ post_macros::page_header(title=page.title) }} + + {% if page.date %} +
+ Posted on {{ page.date | date(format="%Y-%m-%d") }} + + {% if page.draft %} + DRAFT + {% endif %} +
+ {% if page.updated %} +
+ Updated on {{ page.updated | date(format="%Y-%m-%d") }} +
+ {% endif %} +
+ {{ page.word_count }} words, {{ page.reading_time }} minute read +
+ {% endif %} +
+ + {% if page.extra.tldr %} +
+ tl;dr: + {{ page.extra.tldr }} +
+ {% endif %} + + {# Optional table of contents #} + {% if config.extra.toc | default(value=false) %} + {% if page.toc %} +

Table of Contents

+
    + {% for h1 in page.toc %} +
  • + {{ h1.title }} + {% if h1.children %} +
      + {% for h2 in h1.children %} +
    • + {{ h2.title }} +
    • + + {% if h2.children %} + + {% endif %} + {% endfor %} +
    + {% endif %} +
  • + {% endfor %} +
+ {% endif %} + {% endif %} + +
+ {{ page.content | safe }} +
+ + {% if page.taxonomies and page.taxonomies.tags %} + + {% endif %} +
+
+{% endmacro content %} \ No newline at end of file diff --git a/templates/taxonomy_list.html b/templates/taxonomy_list.html new file mode 100644 index 0000000..c550894 --- /dev/null +++ b/templates/taxonomy_list.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block main_content %} +{{ post_macros::page_header(title=taxonomy.name) }} +

go to all posts.

+ + +{% endblock main_content %} \ No newline at end of file diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html new file mode 100644 index 0000000..40dcee1 --- /dev/null +++ b/templates/taxonomy_single.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block main_content %} +{{ post_macros::page_header(title="posts tagged with " ~ term.name)}} +{%- set parent = get_taxonomy(kind=taxonomy.name) -%} +

go to all tags.

+ +{{ post_macros::list_posts(pages=term.pages)}} +{% endblock main_content %} \ No newline at end of file