From c217e580ee111873cc14195b62574b05c32dad66 Mon Sep 17 00:00:00 2001
From: Mole Shang <135e2@135e2.dev>
Date: Mon, 1 May 2023 16:30:53 +0800
Subject: templates/macros: abstract post-meta section to a new macro
---
templates/home.html | 8 +-------
templates/macros.html | 24 ++++++++++++++++++++++++
templates/page.html | 10 +---------
templates/taxonomy_single.html | 8 +-------
4 files changed, 27 insertions(+), 23 deletions(-)
(limited to 'templates')
diff --git a/templates/home.html b/templates/home.html
index 6c0f0c1..1242955 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -15,13 +15,7 @@
{{ post.content | safe }}
{% endif %}
-
- {% if config.extra.seje_chinese_date %}
- {{ macros::format_chinese_date(year=post.year, month=post.month, day=post.day) }}
- {% else %}
- {{ post.date|date(format="%Y/%m/%d") }}
- {% endif %}
-
+ {{ macros::post_meta(post=post, chinese_date=config.extra.seje_chinese_date, expand=false) }}
{% endfor %}
{# {{ paginator.next }} #}
diff --git a/templates/macros.html b/templates/macros.html
index 416c2b4..04b27bf 100644
--- a/templates/macros.html
+++ b/templates/macros.html
@@ -11,3 +11,27 @@
'廿九', '三十', '三十一'] %}
{% for c in year | as_str %}{{ lut1 | nth(n=c | int) }}{% endfor %}年{{ lut2 | nth(n=month-1)}}月{{ lut2 | nth(n=day-1) }}日
{% endmacro %}
+
+{% macro post_meta(post, chinese_date, expand) %}
+
+ {% if expand %}
{% else %}{% endif %}
+ {% for author in post.authors %}
+ {{ author }}
+ {% endfor %}
+ {% if expand %}
{% else %}{% endif %}
+ {% if expand %}
{% else %}{% endif %}
+ {% if chinese_date %}
+ {{ macros::format_chinese_date(year=post.year, month=post.month, day=post.day) }}
+ {% else %}
+ {{ post.date|date(format="%Y/%m/%d") }}
+ {% endif %}
+ {% if expand %}
{% else %}{% endif %}
+ {% if expand %}
{% else %}
{% endif %}
+ {% if post.taxonomies.tags %}
+ {% for tag in post.taxonomies.tags %}
+ #{{ tag }}
+ {% endfor %}
+ {% endif %}
+ {% if expand %}{% else %}{% endif %}
+
+{% endmacro %}
diff --git a/templates/page.html b/templates/page.html
index 071b0a9..ec3116d 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -10,15 +10,7 @@
{{ page.content | safe }}
-
-
- {% if config.extra.seje_chinese_date %}
- {{ macros::format_chinese_date(year=page.year, month=page.month, day=page.day) }}
- {% else %}
- {{ page.date|date(format="%Y/%m/%d") }}
- {% endif %}
-
-
+ {{ macros::post_meta(post=page, chinese_date=config.extra.seje_chinese_date, expand=true) }}
diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html
index 146753a..9dbf19f 100644
--- a/templates/taxonomy_single.html
+++ b/templates/taxonomy_single.html
@@ -17,13 +17,7 @@
{{ post.summary | safe }}
More
-
- {% if config.extra.seje_chinese_date %}
- {{ macros::format_chinese_date(year=post.year, month=post.month, day=post.day) }}
- {% else %}
- {{ post.date|date(format="%Y/%m/%d") }}
- {% endif %}
-
+ {{ macros::post_meta(post=post, chinese_date=config.extra.seje_chinese_date, expand=false) }}
{% endfor %}
{# {{ paginator.next }} #}
--
cgit v1.2.3