diff options
author | Mole Shang <[email protected]> | 2023-05-01 16:30:53 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-05-01 16:41:03 +0800 |
commit | c217e580ee111873cc14195b62574b05c32dad66 (patch) | |
tree | 418872f8ee4bc3c1c963eaea33f3b3cb4d245b11 | |
parent | 2ab777d5827681c6464ac9f705567bb773f6b660 (diff) | |
download | Seje2-c217e580ee111873cc14195b62574b05c32dad66.tar.gz Seje2-c217e580ee111873cc14195b62574b05c32dad66.tar.bz2 Seje2-c217e580ee111873cc14195b62574b05c32dad66.zip |
templates/macros: abstract post-meta section to a new macro
-rw-r--r-- | sass/style.scss | 10 | ||||
-rw-r--r-- | templates/home.html | 8 | ||||
-rw-r--r-- | templates/macros.html | 24 | ||||
-rw-r--r-- | templates/page.html | 10 | ||||
-rw-r--r-- | templates/taxonomy_single.html | 8 |
5 files changed, 37 insertions, 23 deletions
diff --git a/sass/style.scss b/sass/style.scss index 1aa7bc4..706584a 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -14,6 +14,16 @@ body { } } +// General divider used in span +.divider:before { + padding: 0 16px; + content: "//"; +} + +.tag { + padding: 6px; + } + @import "_partial/_header"; @import "_partial/_post"; @import "_partial/_archive"; 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 %} </div> - <div class="post-meta"> - {% 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 %} - </div> + {{ macros::post_meta(post=post, chinese_date=config.extra.seje_chinese_date, expand=false) }} </article> {% 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) %} +<div class="post-meta" {% if expand %}style="text-align: end"{% endif %}> + {% if expand %}<div>{% else %}<span>{% endif %} + {% for author in post.authors %} + {{ author }} + {% endfor %} + {% if expand %}</div>{% else %}</span>{% endif %} + {% if expand %}<div>{% else %}<span class="divider">{% 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 %}</div>{% else %}</span>{% endif %} + {% if expand %}<div>{% else %}<span class="divider">{% endif %} + {% if post.taxonomies.tags %} + {% for tag in post.taxonomies.tags %} + <span class="tag"><a href="{{ get_taxonomy_url(kind="tags", name=tag) | safe }}">#{{ tag }}</a></span> + {% endfor %} + {% endif %} + {% if expand %}</div>{% else %}</span>{% endif %} +</div> +{% 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 @@ <div class="post-content"> {{ page.content | safe }} </div> - <div class="post-meta"> - <span class="post-time"> - {% 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 %} - </span> - </div> + {{ macros::post_meta(post=page, chinese_date=config.extra.seje_chinese_date, expand=true) }} </article> <div class="prev_next"> 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 }} <a href="{{ post.permalink }}" class="More">More</a> </div> - <div class="post-meta"> - {% 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 %} - </div> + {{ macros::post_meta(post=post, chinese_date=config.extra.seje_chinese_date, expand=false) }} </article> {% endfor %} {# {{ paginator.next }} #} |