refactor: refactor configuration logic
This commit is contained in:
+98
-83
@@ -7,77 +7,18 @@ spec:
|
||||
- group: basic
|
||||
label: 基本设置
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: index_notice_title
|
||||
label: 首页公告标题
|
||||
value: "Hello Terminal!"
|
||||
- $formkit: textarea
|
||||
name: index_notice_content
|
||||
label: 首页公告内容
|
||||
value: "一款 Terminal 风格的 Halo 主题."
|
||||
- $formkit: checkbox
|
||||
name: show_toc
|
||||
label: 显示文章目录
|
||||
value: true
|
||||
help: 开启后将在文章页面显示文章目录
|
||||
- $formkit: checkbox
|
||||
name: pjax
|
||||
name: pjax_enable
|
||||
label: 启用 PJAX
|
||||
help: 是否启用 PJAX, 默认关闭, 开启后点击站内链接时只更新主要内容区域而不是整个页面 (可能与一些插件存在兼容问题)
|
||||
value: false
|
||||
- group: page
|
||||
label: 页面配置
|
||||
formSchema:
|
||||
- $formkit: checkbox
|
||||
name: archives_tags
|
||||
label: 归档页显示文章标签
|
||||
value: false
|
||||
|
||||
- $formkit: checkbox
|
||||
name: show_pin
|
||||
label: 主页置顶文章显示 pin 图标
|
||||
value: true
|
||||
|
||||
- $formkit: select
|
||||
name: pin_pos
|
||||
label: pin 图标显示位置
|
||||
options:
|
||||
- label: "left"
|
||||
value: "pin-left"
|
||||
- label: "above"
|
||||
value: "pin-above"
|
||||
|
||||
- $formkit: text
|
||||
name: archives_title
|
||||
label: 归档页标题自定义
|
||||
value:
|
||||
- $formkit: text
|
||||
name: categories_title
|
||||
label: 分类页(复数) 标题自定义
|
||||
value:
|
||||
- $formkit: text
|
||||
name: category_title
|
||||
label: 分类页标题自定义
|
||||
value:
|
||||
- $formkit:
|
||||
name: tags_title
|
||||
label: 标签页(复数) 标题自定义
|
||||
value:
|
||||
- $formkit:
|
||||
name: tag_title
|
||||
label: 标签页标题自定义
|
||||
value:
|
||||
- $formkit: text
|
||||
name: links_title
|
||||
label: 友链页标题自定义
|
||||
value:
|
||||
|
||||
- group: style
|
||||
label: 样式设置
|
||||
label: 全局样式
|
||||
formSchema:
|
||||
- $formkit: checkbox
|
||||
label: 使用系统字体
|
||||
name: system_font
|
||||
name: system_font_enable
|
||||
value: false
|
||||
help: 开启后将优先使用访问者的系统字体
|
||||
|
||||
@@ -87,21 +28,6 @@ spec:
|
||||
value: false
|
||||
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: checkbox
|
||||
name: custom_font_enable
|
||||
id: custom_font_enable
|
||||
@@ -120,6 +46,21 @@ spec:
|
||||
help: "填写上传字体文件内部声明的 字体全名 或 PostScript. 如果和上传的字体文件不匹配, 将从网络上下载字体"
|
||||
value: ""
|
||||
|
||||
- $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
|
||||
@@ -219,15 +160,89 @@ spec:
|
||||
height: 150px
|
||||
value: ""
|
||||
help: 可填写自定义的 CSS, 会覆盖主题的样式
|
||||
- group: index_page
|
||||
label: 首页
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: notice_title
|
||||
label: 公告标题
|
||||
value: "Hello Terminal!"
|
||||
- $formkit: textarea
|
||||
name: notice_content
|
||||
label: 公告内容
|
||||
value: "一款 Terminal 风格的 Halo 主题."
|
||||
- $formkit: checkbox
|
||||
name: show_sns
|
||||
label: 展示社交资料
|
||||
value: true
|
||||
- $formkit: checkbox
|
||||
name: show_pin
|
||||
label: 置顶文章显示 pin 图标
|
||||
value: true
|
||||
- $formkit: select
|
||||
name: pin_pos
|
||||
label: pin 图标显示位置
|
||||
options:
|
||||
- label: "left"
|
||||
value: "pin-left"
|
||||
- label: "above"
|
||||
value: "pin-above"
|
||||
|
||||
- group: post_page
|
||||
label: 文章页
|
||||
formSchema:
|
||||
- $formkit: checkbox
|
||||
name: show_toc
|
||||
label: 显示文章目录
|
||||
value: true
|
||||
|
||||
- group: categories_page
|
||||
label: 分类页
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: title_s
|
||||
label: 分类页(复数) 标题自定义
|
||||
value:
|
||||
- $formkit: text
|
||||
name: title
|
||||
label: 分类页标题自定义
|
||||
value:
|
||||
|
||||
- group: archives_page
|
||||
label: 归档页
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: title
|
||||
label: 归档页标题自定义
|
||||
value:
|
||||
- $formkit: checkbox
|
||||
name: show_tags
|
||||
label: 归档页显示文章标签
|
||||
value: false
|
||||
|
||||
- group: tags_page
|
||||
label: 标签页
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: title_s
|
||||
label: 标签页(复数) 标题自定义
|
||||
value:
|
||||
- $formkit: text
|
||||
name: title
|
||||
label: 标签页标题自定义
|
||||
value:
|
||||
|
||||
- group: links_page
|
||||
label: 友链页
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: title
|
||||
label: 友链页标题自定义
|
||||
value:
|
||||
|
||||
- group: sns
|
||||
label: 社交资料
|
||||
formSchema:
|
||||
- $formkit: checkbox
|
||||
name: switch
|
||||
label: 全局开关
|
||||
value: true
|
||||
help: 关闭后不会显示社交资料
|
||||
- $formkit: checkbox
|
||||
name: rss
|
||||
label: RSS
|
||||
@@ -269,7 +284,7 @@ spec:
|
||||
value:
|
||||
|
||||
- group: icp
|
||||
label: 备案设置
|
||||
label: 备案
|
||||
formSchema:
|
||||
- $formkit: text
|
||||
name: icp_text
|
||||
|
||||
@@ -34,7 +34,7 @@ html[pixel_style='true'] {
|
||||
--font-theme-default: 'Fusion Pixel 12px P zh_hans';
|
||||
}
|
||||
|
||||
html[system_font='true']:not([pixel_style='true']) {
|
||||
html[system_font_enable='true']:not([pixel_style='true']) {
|
||||
--font-theme-default: system-ui;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
@@ -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
@@ -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
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user