refactor: refactor configuration logic

This commit is contained in:
Erzbir
2025-11-18 13:11:05 +08:00
parent 7bf2286776
commit 8adc06c65a
11 changed files with 116 additions and 101 deletions
+2 -2
View File
@@ -7,7 +7,7 @@
<article class="post">
<header>
<h1 class="post-title"
th:with="title=${theme.config.page.archives_title ?: page.archives.title ?: 'Archives'}"
th:with="title=${theme.config.archives_page.title ?: page.archives.title ?: 'Archives'}"
th:text="${title}">
Archives
</h1>
@@ -28,7 +28,7 @@
<a data-pjax th:href="@{${post.status.permalink}}"><span class="post-list-title"
th:text="${post.spec.title}">Post Title</span></a>
<th:block th:replace="~{modules/tag-list(post = ${post})}"
th:if="${theme.config.page.archives_tags}"/></div>
th:if="${theme.config.page.show_tags}"/></div>
</li>
</th:block>
</ul>
+1 -1
View File
@@ -7,7 +7,7 @@
<article class="post">
<header>
<h1 class="post-title"
th:with="title=${theme.config.page.categories_title ?: page.categories.title ?: 'Categories'}"
th:with="title=${theme.config.categories_page.title_s ?: page.categories.title ?: 'Categories'}"
th:text="${title}">
Categories
</h1>
+1 -1
View File
@@ -7,7 +7,7 @@
<article class="post">
<header>
<h1 class="post-title"
th:with="title=${theme.config.page.category_title ?: page.category.title ?: 'Category'}"
th:with="title=${theme.config.categories_page.title ?: page.category.title ?: 'Category'}"
th:text="|${title}: ${category.spec.displayName} [${category.status.visiblePostCount ?: 0}]|">
Category: Category name [n]
</h1>
+5 -5
View File
@@ -5,18 +5,18 @@
>
<th:block th:fragment="content">
<section class="index-content framed"
th:if="${not #strings.isEmpty(theme.config.basic.index_notice_title) and not #strings.isEmpty(theme.config.basic.index_notice_content)}">
<h1 class="typed-text" th:text="${theme.config.basic.index_notice_title}"></h1>
<div th:utext="${theme.config.basic.index_notice_content}"></div>
th:if="${not #strings.isEmpty(theme.config.index_page.notice_title) and not #strings.isEmpty(theme.config.index_page.notice_content)}">
<h1 class="typed-text" th:text="${theme.config.index_page.notice_title}"></h1>
<div th:utext="${theme.config.index_page.notice_content}"></div>
</section>
<section id="sns" th:if="${theme.config.sns.switch}">
<section id="sns" th:if="${theme.config.index_page.show_sns}">
<th:block th:replace="~{modules/sns}"/>
</section>
<section class="posts">
<article class="post on-list" th:each="post : ${posts.items}">
<header>
<h1 class="post-title">
<span class="pin" th:classappend="${theme.config?.page?.pin_pos}" th:if="${post.spec.pinned} and ${theme.config?.page?.show_pin}">
<span class="pin" th:classappend="${theme.config?.index_page?.pin_pos}" th:if="${post.spec.pinned} and ${theme.config?.index_page?.show_pin}">
<svg class="icon-regular" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="currentColor" d="M5 2h14a1 1 0 0 1 1 1v19.143a.5.5 0 0 1-.766.424L12 18.03l-7.234 4.536A.5.5 0 0 1 4 22.143V3a1 1 0 0 1 1-1m13 2H6v15.432l6-3.761l6 3.761z" />
</svg>
+1 -1
View File
@@ -5,7 +5,7 @@
<article class="post">
<header>
<h1 class="post-title"
th:with="title=${theme.config.page.links_title ?: page.links.title ?: 'Links'}"
th:with="title=${theme.config.links_page.title ?: page.links.title ?: 'Links'}"
th:text="${title}">
Links
</h1>
+4 -4
View File
@@ -9,8 +9,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title th:text="${title}"></title>
<script no-pjax th:inline="javascript">
let system_font = /*[[${theme.config.style.system_font}]]*/;
document.documentElement.setAttribute("system_font", system_font);
let system_font_enable = /*[[${theme.config.style.system_font_enable}]]*/;
document.documentElement.setAttribute("system_font_enable", system_font_enable);
</script>
<script no-pjax th:inline="javascript">
let dark_theme = /*[[${theme.config.style.dark_color_scheme}]]*/;
@@ -61,7 +61,7 @@
</script>
<link no-pjax rel="stylesheet" th:href="@{/assets/dist/main.css?v={version}(version=${theme.spec.version})}"/>
<script no-pjax type="module" th:src="@{/assets/dist/main.js?v={version}(version=${theme.spec.version})}"></script>
<script no-pjax type="module" th:if="${theme.config.basic.pjax}"
<script no-pjax type="module" th:if="${theme.config.basic.pjax_enable}"
th:src="@{/assets/dist/libs/pjax.js?v={version}(version=${theme.spec.version})}"></script>
<script no-pjax th:inline="javascript">
function applyRawCss(text) {
@@ -74,7 +74,7 @@
applyRawCss(custom);
</script>
<th:block
th:if="${theme.config?.style?.custom_font_enable and not theme.config?.style?.system_font}"
th:if="${theme.config?.style?.custom_font_enable and not theme.config?.style?.system_font_enable}"
th:with="font=${#objects.nullSafe(theme.config?.style?.custom_font_file, #theme.assets('/dist/JetBrainsMono-Regular.woff2'))},
ext=${font.substring(font.lastIndexOf('.') + 1)},
format=${ext == 'woff2' ? 'woff2' :
+1 -1
View File
@@ -19,7 +19,7 @@
<div th:utext="${post.content.content}" id="content">Post Content</div>
</section>
</article>
<nav id="toc" th:if="${theme.config.basic.show_toc}" class="toc">
<nav id="toc" th:if="${theme.config.post_page.show_toc}" class="toc">
<button id="toc-toggle" class="toc-toggle" aria-label="Hide Table of Contents"></button>
<div id="toc-content" class="toc-content"></div>
</nav>
+1 -1
View File
@@ -7,7 +7,7 @@
<article class="post">
<header>
<h1 class="post-title"
th:with="title=${theme.config.page.tag_title ?: page.tag.title ?: 'Tag'}"
th:with="title=${theme.config.tags_page.title ?: page.tag.title ?: 'Tag'}"
th:text="|${title}: ${tag.spec.displayName} [${tag.status.visiblePostCount ?: 0}]|">
Tag: Tag name [n]
</h1>
+1 -1
View File
@@ -7,7 +7,7 @@
<article class="post">
<header>
<h1 class="post-title"
th:with="title=${theme.config.page.tags_title ?: page.tags.title ?: 'Tags'}"
th:with="title=${theme.config.tags_page.title_s ?: page.tags.title ?: 'Tags'}"
th:text="${title}">
Tags
</h1>