支持自定义导航栏

This commit is contained in:
liuzhihang 2022-12-13 00:14:41 +08:00
parent 9bcf6e6bc6
commit 5402f862ac
5 changed files with 35 additions and 37 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "halo-theme-hao", "name": "halo-theme-hao",
"version": "1.0.2", "version": "1.0.3",
"dependencies": { "dependencies": {
} }
} }

View File

@ -190,30 +190,30 @@ spec:
value: category value: category
- label: 标签 - label: 标签
value: tag value: tag
# - label: 自定义分类 - label: 自定义分类
# value: custom-category value: custom-category
# - label: 自定义标签 - label: 自定义标签
# value: custom-tag value: custom-tag
- label: 自定义路径 - label: 自定义路径
value: custom-url value: custom-url
# - $formkit: repeater - $formkit: repeater
# if: "$get(nav).value === 'custom-category'" if: "$get(nav).value === 'custom-category'"
# name: navCustomCategory name: navCustomCategory
# label: 自定义分类 label: 自定义分类
# value: [ ] value: [ ]
# children: children:
# - $formkit: categorySelect - $formkit: categorySelect
# name: category name: category
# label: 分类 label: 分类
# - $formkit: repeater - $formkit: repeater
# if: "$get(nav).value === 'custom-tag'" if: "$get(nav).value === 'custom-tag'"
# name: navCustomTag name: navCustomTag
# label: 自定义标签 label: 自定义标签
# value: [ ] value: [ ]
# children: children:
# - $formkit: tagSelect - $formkit: tagSelect
# name: tag name: tag
# label: 标签 label: 标签
- $formkit: repeater - $formkit: repeater
if: "$get(nav).value === 'custom-url'" if: "$get(nav).value === 'custom-url'"
name: navCustomUrl name: navCustomUrl
@ -439,9 +439,9 @@ spec:
help: "小于 0 则展示全部标签" help: "小于 0 则展示全部标签"
- $formkit: number - $formkit: number
name: categoryQuantity name: categoryQuantity
label: 目录数量 label: 分类数量
value: -1 value: -1
help: "小于 0 则展示全部目录" help: "小于 0 则展示全部分类"
- group: footer - group: footer
label: 页脚 label: 页脚

View File

@ -1,21 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"> <html lang="en" xmlns:th="http://www.thymeleaf.org">
<!-- 目录条 --> <!-- 目录条 -->
<div id="category-bar" th:fragment="category-bar"> <div id="category-bar" th:fragment="custom-category">
<div class="category-bar-items" id="category-bar-items"> <div class="category-bar-items" id="category-bar-items">
<div class="category-bar-item select" id="category-bar-home"> <div class="category-bar-item select" id="category-bar-home">
<a href="/">首页</a> <a href="/">首页</a>
</div> </div>
<th:block th:with="categoryNames = ${theme.config.layout.navCustomCategory}"> <th:block th:each="customCategory : ${theme.config.layout.navCustomCategory}">
<div class="category-bar-item" <div class="category-bar-item"
th:each="categoryName : ${categoryNames}"> th:each="categoryItem : ${categoryFinder.getByName(customCategory.category)}"
<!--<a th:href="@{${categoryItem.status.permalink}}" th:text="${categoryItem.spec.displayName}"></a>--> th:id="${categoryItem.spec.displayName}">
<a th:text="${categoryFinder.getByName(categoryName)}"></a> <a th:href="@{${categoryItem.status.permalink}}" th:text="${categoryItem.spec.displayName}"></a>
</div> </div>
</th:block> </th:block>
</div> </div>
<a th:replace="modules/bar/more :: more">更多</a> <a th:replace="modules/bar/more :: more">更多</a>
</div> </div>

View File

@ -7,15 +7,14 @@
<a href="/">首页</a> <a href="/">首页</a>
</div> </div>
<th:block th:with="tags = ${theme.config.layout.navCustomTag}"> <th:block th:each="customTag : ${theme.config.layout.navCustomTag}">
<div class="category-bar-item" <div class="category-bar-item"
th:each="tagItem : ${tags}" th:each="tagItem : ${tagFinder.getByName(customTag.tag)}"
th:id="${tagItem.spec.displayName}"> th:id="${tagItem.spec.displayName}">
<a th:href="@{${tagItem.status.permalink}}" th:text="${tagItem.spec.displayName}"></a> <a th:href="@{${tagItem.status.permalink}}" th:text="${tagItem.spec.displayName}"></a>
</div> </div>
</th:block> </th:block>
</div> </div>
<a th:replace="modules/bar/more :: more">更多</a> <a th:replace="modules/bar/more :: more">更多</a>
</div> </div>

View File

@ -13,5 +13,5 @@ spec:
repo: 'https://github.com/liuzhihang/halo-theme-hao' repo: 'https://github.com/liuzhihang/halo-theme-hao'
settingName: "theme-hao-setting" settingName: "theme-hao-setting"
configMapName: "theme-hao-configMap" configMapName: "theme-hao-configMap"
version: 1.0.2 version: 1.0.3
require: 2.0.0 require: 2.0.0