feat: custom time format

This commit is contained in:
Erzbir
2025-11-18 00:13:03 +08:00
parent 11ebd6f2bb
commit 641427aec8
4 changed files with 51 additions and 8 deletions
+24
View File
@@ -61,11 +61,35 @@ spec:
name: system_font name: system_font
value: false value: false
help: 开启后将优先使用访问者的系统字体 help: 开启后将优先使用访问者的系统字体
- $formkit: checkbox - $formkit: checkbox
name: pixel_style name: pixel_style
label: 默认像素化风格 label: 默认像素化风格
value: false value: false
help: 开启后将默认使用像素风格字体及图标 help: 开启后将默认使用像素风格字体及图标
- $formkit: select
name: time_style
id: time_style
label: 时间格式
value: "yyyy-MM-dd"
options:
- label: "yyyy-MM-ddTHH:mm:ssXXX"
value: "yyyy-MM-dd''T''HH:mm:ssXXX"
- label: "yyyy-MM-dd HH:mm:ss"
value: "yyyy-MM-dd'' ''HH:mm:ss"
- label: "yyyy-MM-dd"
value: "yyyy-MM-dd"
- label: "custom"
value: "custom"
- $formkit: text
if: "$get(time_style).value === 'custom'"
name: custom_time_style
label: 自定义时间格式
placeholder: "yyyy-MM-dd"
validation: "required"
- $formkit: select - $formkit: select
name: default_scheme_mode name: default_scheme_mode
label: 默认配色方案 label: 默认配色方案
+19 -2
View File
@@ -17,12 +17,29 @@
<ul> <ul>
<th:block th:each="month : ${archive.months}"> <th:block th:each="month : ${archive.months}">
<li class="post-list" th:each="post : ${month.posts}"> <li class="post-list" th:each="post : ${month.posts}">
<div class="post-meta">
<time class="post-time"
th:text="${#dates.format(post.spec.publishTime, '__${theme.config.style.time_style == 'custom' ?
theme.config.style.custom_time_style : theme.config.style.time_style}__')}">
Publish
Time
</time>
<a data-pjax th:href="@{${post.status.permalink}}"> <a data-pjax th:href="@{${post.status.permalink}}">
<time th:text="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')}">Publish Time</time>
<span>&nbsp;::&nbsp;</span>
<span class="post-list-title" th:text="${post.spec.title}">Post Title</span> <span class="post-list-title" th:text="${post.spec.title}">Post Title</span>
</a> </a>
<span class="post-tags">
<span class="post-tag" th:each="tag : ${post.tags}">
<a data-pjax
th:href="@{${tag.status.permalink}}"
th:title="${tag.spec.displayName}"
th:text="'#'+${tag.spec.displayName}"
>#Tag</a>
</span>
</span>
</div>
</li> </li>
</th:block> </th:block>
</ul> </ul>
</th:block> </th:block>
+2 -1
View File
@@ -20,7 +20,8 @@
</h1> </h1>
<div class="post-meta"> <div class="post-meta">
<time class="post-date" <time class="post-date"
th:text="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')}">Publish Time</time> th:text="${#dates.format(post.spec.publishTime, '__${theme.config.style.time_style == 'custom' ?
theme.config.style.custom_time_style : theme.config.style.time_style}__')}">Publish Time</time>
<span class="post-author" <span class="post-author"
th:with="contributor = ${post.contributors[0]}" th:with="contributor = ${post.contributors[0]}"
th:text="${contributor.displayName}">Author</span> th:text="${contributor.displayName}">Author</span>
+3 -2
View File
@@ -8,8 +8,9 @@
<header> <header>
<h1 class="post-title" th:text="${post.spec.title}">Post Title</h1> <h1 class="post-title" th:text="${post.spec.title}">Post Title</h1>
<div class="post-meta"> <div class="post-meta">
<time class="post-date" <time class="post-time"
th:text="${#dates.format(post.spec.publishTime,'yyyy-MM-dd')}">Publish Time th:text="${#dates.format(post.spec.publishTime, '__${theme.config.style.time_style == 'custom' ?
theme.config.style.custom_time_style : theme.config.style.time_style}__')}">Publish Time
</time> </time>
<span class="post-author" th:text="${post.owner.displayName}">Author</span> <span class="post-author" th:text="${post.owner.displayName}">Author</span>
</div> </div>