summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/archives.html5
-rw-r--r--templates/base.html4
-rw-r--r--templates/components.html (renamed from templates/macros.html)36
-rw-r--r--templates/home.html6
-rw-r--r--templates/navbar.html4
-rw-r--r--templates/page.html4
-rw-r--r--templates/section.html4
-rw-r--r--templates/shortcodes/shikwasa.html21
-rw-r--r--templates/taxonomy_list.html7
-rw-r--r--templates/taxonomy_single.html6
10 files changed, 43 insertions, 54 deletions
diff --git a/templates/archives.html b/templates/archives.html
index e691c86..79feb9d 100644
--- a/templates/archives.html
+++ b/templates/archives.html
@@ -5,11 +5,8 @@
<ul class="post-archive">
{# Group the posts by year #}
{% set map = get_section(path="_index.md") | get(key="pages") | group_by(attribute="year") %}
- {% set_global years = [] %}
{# Convert the years map to an array (since maps do not have determined order) #}
- {% for year, ignored in map %}
- {% set_global years = years | concat(with=year) %}
- {% endfor %}
+ {% set_global years = [year for year, ignored in map] %}
{% for year in years | sort | reverse %}
<div class="years">
diff --git a/templates/base.html b/templates/base.html
index 15f1dd7..c2fd24d 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -4,7 +4,7 @@
{% block rss %}
<link rel="alternate" type="application/rss+xml" title="RSS" href="{{ get_url(path="atom.xml", trailing_slash=false) }}">
{% endblock %}
- {% set sub_title = section.title | default(value=page.title | default(value='')) %}
+ {% set sub_title = section?.title | default(value=page?.title | default(value='')) %}
{% if sub_title %}
{% set title = sub_title ~ ' - ' ~ trans(key="title") %}
{% else %}
@@ -28,7 +28,7 @@
<title>{{ title }}</title>
<meta charset="utf-8">
<meta name="title" content="{{ title }}">
- <meta name="description" content="{{ section.description | default(value=page.description | default(value=config.description)) }}">
+ <meta name="description" content="{{ section?.description | default(value=page?.description | default(value=config.description)) }}">
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
<link rel="stylesheet" href="{{ config.base_url }}/style.css">
diff --git a/templates/macros.html b/templates/components.html
index 04b27bf..5e07ac0 100644
--- a/templates/macros.html
+++ b/templates/components.html
@@ -1,4 +1,4 @@
-{% macro format_chinese_date(year, month, day) %}
+{% component format_chinese_date(year, month, day) %}
{% set lut1 = ["〇", "一", "二", "三", "四", "五", "六", "七", "八", "九"] %}
{% set lut2 = [
'一', '二', '三', '四',
@@ -9,10 +9,10 @@
'廿一', '廿二', '廿三', '廿四',
'廿五', '廿六', '廿七', '廿八',
'廿九', '三十', '三十一'] %}
-{% for c in year | as_str %}{{ lut1 | nth(n=c | int) }}{% endfor %}年{{ lut2 | nth(n=month-1)}}月{{ lut2 | nth(n=day-1) }}日
-{% endmacro %}
+{% for c in year | str %}{{ lut1 | nth(n=c | int) }}{% endfor %}年{{ lut2 | nth(n=month-1)}}月{{ lut2 | nth(n=day-1) }}日
+{% endcomponent format_chinese_date %}
-{% macro post_meta(post, chinese_date, expand) %}
+{% component 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 %}
@@ -21,7 +21,7 @@
{% 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) }}
+ {{ <format_chinese_date year={post.year} month={post.month} day={post.day} /> }}
{% else %}
{{ post.date|date(format="%Y/%m/%d") }}
{% endif %}
@@ -34,4 +34,28 @@
{% endif %}
{% if expand %}</div>{% else %}</span>{% endif %}
</div>
-{% endmacro %}
+{% endcomponent post_meta %}
+
+{% component shikwasa(subtitle, author, image, media) %}
+<link
+ rel="stylesheet"
+ href="https://cdn.jsdelivr.net/npm/shikwasa@2.2.0/dist/style.css"
+/>
+<script src="https://cdn.jsdelivr.net/npm/shikwasa@2.2.0/dist/shikwasa.min.js"></script>
+<div class="podcast">
+ <script>
+ const player = new Shikwasa.Player({
+ container: () => document.querySelector(".podcast"),
+ audio: {
+ title: "{{subtitle}}",
+ artist: "{{author}}",
+ cover: "{{image | safe}}",
+ src: "{{media | safe}}",
+ },
+ fixed: {
+ type: "static",
+ },
+ });
+ </script>
+</div>
+{% endcomponent shikwasa %}
diff --git a/templates/home.html b/templates/home.html
index 1242955..298c232 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -1,7 +1,5 @@
{% extends "base.html" %}
-{% import "macros.html" as macros %}
-
{% block content %}
<section class="posts">
{% for post in paginator.pages %}
@@ -15,10 +13,10 @@
{{ post.content | safe }}
{% endif %}
</div>
- {{ macros::post_meta(post=post, chinese_date=config.extra.seje_chinese_date, expand=false) }}
+ {{ <post_meta post={post} chinese_date={config.extra.seje_chinese_date} expand={false} /> }}
</article>
{% endfor %}
{# {{ paginator.next }} #}
</section>
{% include "paginator.html" %}
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/templates/navbar.html b/templates/navbar.html
index 07abdb9..f92dbdc 100644
--- a/templates/navbar.html
+++ b/templates/navbar.html
@@ -5,8 +5,8 @@
<li class="menu-item">
{% set url_inner = item['url'] | replace(from="$BASE_URL", to="") %}
{% set url = url_inner ~ '/'%}
- {% if page.path or section.path %}
- {% set path = page.path|default(value = section.path) %}
+ {% if page?.path or section?.path %}
+ {% set path = page?.path | default(value=section?.path) %}
{% if url == path or url_inner == path %}
<a href="{{ item['url'] | replace(from="$BASE_URL", to=config.base_url) }}" class="current-menu-item-link">{{ trans(key=item['name']) }}</a>
{% else %}
diff --git a/templates/page.html b/templates/page.html
index f795876..791a8a1 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -1,7 +1,5 @@
{% extends "base.html" %}
-{% import "macros.html" as macros %}
-
{% block content %}
<article class="post">
<div class="post-title">
@@ -10,7 +8,7 @@
<div class="post-content">
{{ page.content | safe }}
</div>
- {{ macros::post_meta(post=page, chinese_date=config.extra.seje_chinese_date, expand=true) }}
+ {{ <post_meta post={page} chinese_date={config.extra.seje_chinese_date} expand={true} /> }}
</article>
<div class="prev_next">
diff --git a/templates/section.html b/templates/section.html
index bca7f6b..a3ffc75 100644
--- a/templates/section.html
+++ b/templates/section.html
@@ -1,7 +1,5 @@
{% extends "base.html" %}
-{% import "macros.html" as macros %}
-
{% block content %}
<article class="post">
<div class="post-title">
@@ -13,7 +11,7 @@
<div class="post-meta">
<span class="post-time">
{% if config.extra.seje_chinese_date %}
- {{ macros::format_chinese_date(year=section.extra.year, month=section.extra.month, day=section.extra.day) }}
+ {{ <format_chinese_date year={section.extra.year} month={section.extra.month} day={section.extra.day} /> }}
{% else %}
{{ section.extra.date|date(format="%Y/%m/%d") }}
{% endif %}
diff --git a/templates/shortcodes/shikwasa.html b/templates/shortcodes/shikwasa.html
deleted file mode 100644
index 93c4601..0000000
--- a/templates/shortcodes/shikwasa.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<link
- rel="stylesheet"
- href="https://cdn.jsdelivr.net/npm/shikwasa@2.2.0/dist/style.css"
-/>
-<script src="https://cdn.jsdelivr.net/npm/shikwasa@2.2.0/dist/shikwasa.min.js"></script>
-<div class="podcast">
- <script>
- const player = new Shikwasa.Player({
- container: () => document.querySelector(".podcast"),
- audio: {
- title: "{{subtitle}}",
- artist: "{{author}}",
- cover: "{{image | safe}}",
- src: "{{media | safe}}",
- },
- fixed: {
- type: "static",
- },
- });
- </script>
-</div>
diff --git a/templates/taxonomy_list.html b/templates/taxonomy_list.html
index 222711c..4aad956 100644
--- a/templates/taxonomy_list.html
+++ b/templates/taxonomy_list.html
@@ -6,11 +6,8 @@
<ul class="post-archive">
{# Group the posts by year #}
{% set map = term.pages | group_by(attribute="year") %}
- {% set_global years = [] %}
{# Convert the years map to an array (since maps do not have determined order) #}
- {% for year, ignored in map %}
- {% set_global years = years | concat(with=year) %}
- {% endfor %}
+ {% set_global years = [year for year, ignored in map] %}
<div class="term-name"><a href="{{ term.permalink }}" class="term-name">#{{ term.name }}</a></div>
@@ -29,4 +26,4 @@
</ul>
{% endfor %}
</section>
-{% endblock %} \ No newline at end of file
+{% endblock %}
diff --git a/templates/taxonomy_single.html b/templates/taxonomy_single.html
index dec55cc..98de3d0 100644
--- a/templates/taxonomy_single.html
+++ b/templates/taxonomy_single.html
@@ -1,7 +1,5 @@
{% extends "base.html" %}
-{% import "macros.html" as macros %}
-
{% block content %}
{% if paginator %}
{% set pages = paginator.pages %}
@@ -19,7 +17,7 @@
{{ post.summary | safe }}
<a href="{{ post.permalink }}" class="More">More</a>
</div>
- {{ macros::post_meta(post=post, chinese_date=config.extra.seje_chinese_date, expand=false) }}
+ {{ <post_meta post={post} chinese_date={config.extra.seje_chinese_date} expand={false} /> }}
</article>
{% endfor %}
{# {{ paginator.next }} #}
@@ -27,4 +25,4 @@
{% if paginator %}
{% include "paginator.html" %}
{% endif %}
-{% endblock %} \ No newline at end of file
+{% endblock %}