Skip to content

Commit

Permalink
Merge pull request #32 from liuzhihang/dev
Browse files Browse the repository at this point in the history
支持自定义导航栏
  • Loading branch information
liuzhihang authored Dec 12, 2022
2 parents 672334e + 5402f86 commit bf012e2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "halo-theme-hao",
"version": "1.0.2",
"version": "1.0.3",
"dependencies": {
}
}
48 changes: 24 additions & 24 deletions settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,30 @@ spec:
value: category
- label: 标签
value: tag
# - label: 自定义分类
# value: custom-category
# - label: 自定义标签
# value: custom-tag
- label: 自定义分类
value: custom-category
- label: 自定义标签
value: custom-tag
- label: 自定义路径
value: custom-url
# - $formkit: repeater
# if: "$get(nav).value === 'custom-category'"
# name: navCustomCategory
# label: 自定义分类
# value: [ ]
# children:
# - $formkit: categorySelect
# name: category
# label: 分类
# - $formkit: repeater
# if: "$get(nav).value === 'custom-tag'"
# name: navCustomTag
# label: 自定义标签
# value: [ ]
# children:
# - $formkit: tagSelect
# name: tag
# label: 标签
- $formkit: repeater
if: "$get(nav).value === 'custom-category'"
name: navCustomCategory
label: 自定义分类
value: [ ]
children:
- $formkit: categorySelect
name: category
label: 分类
- $formkit: repeater
if: "$get(nav).value === 'custom-tag'"
name: navCustomTag
label: 自定义标签
value: [ ]
children:
- $formkit: tagSelect
name: tag
label: 标签
- $formkit: repeater
if: "$get(nav).value === 'custom-url'"
name: navCustomUrl
Expand Down Expand Up @@ -439,9 +439,9 @@ spec:
help: "小于 0 则展示全部标签"
- $formkit: number
name: categoryQuantity
label: 目录数量
label: 分类数量
value: -1
help: "小于 0 则展示全部目录"
help: "小于 0 则展示全部分类"

- group: footer
label: 页脚
Expand Down
13 changes: 6 additions & 7 deletions templates/modules/bar/custom-category.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<!DOCTYPE html>
<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-item select" id="category-bar-home">
<a href="/">首页</a>
</div>

<th:block th:with="categoryNames = ${theme.config.layout.navCustomCategory}">

<th:block th:each="customCategory : ${theme.config.layout.navCustomCategory}">
<div class="category-bar-item"
th:each="categoryName : ${categoryNames}">
<!--<a th:href="@{${categoryItem.status.permalink}}" th:text="${categoryItem.spec.displayName}"></a>-->
<a th:text="${categoryFinder.getByName(categoryName)}"></a>
th:each="categoryItem : ${categoryFinder.getByName(customCategory.category)}"
th:id="${categoryItem.spec.displayName}">
<a th:href="@{${categoryItem.status.permalink}}" th:text="${categoryItem.spec.displayName}"></a>
</div>

</th:block>

</div>
<a th:replace="modules/bar/more :: more">更多</a>
</div>
Expand Down
7 changes: 3 additions & 4 deletions templates/modules/bar/custom-tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
<a href="/">首页</a>
</div>

<th:block th:with="tags = ${theme.config.layout.navCustomTag}">

<th:block th:each="customTag : ${theme.config.layout.navCustomTag}">
<div class="category-bar-item"
th:each="tagItem : ${tags}"
th:each="tagItem : ${tagFinder.getByName(customTag.tag)}"
th:id="${tagItem.spec.displayName}">
<a th:href="@{${tagItem.status.permalink}}" th:text="${tagItem.spec.displayName}"></a>
</div>

</th:block>

</div>
<a th:replace="modules/bar/more :: more">更多</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ spec:
repo: 'https://github.com/liuzhihang/halo-theme-hao'
settingName: "theme-hao-setting"
configMapName: "theme-hao-configMap"
version: 1.0.2
version: 1.0.3
require: 2.0.0

0 comments on commit bf012e2

Please sign in to comment.