refactor(theme): improve archive link resolution logic and dynamic tab naming
这个提交包含在:
+2
-2
@@ -71,7 +71,7 @@ spec:
|
||||
position: up
|
||||
label: 归档
|
||||
icon: archive
|
||||
url: /archives
|
||||
url: ""
|
||||
external: false
|
||||
- enabled: true
|
||||
type: categories
|
||||
@@ -279,7 +279,7 @@ spec:
|
||||
- $formkit: text
|
||||
name: url
|
||||
label: 链接地址
|
||||
help: 搜索入口可留空;其他入口留空时不会跳转。
|
||||
help: 内置入口可留空并自动使用 Halo 路由;自定义入口留空时不会跳转。
|
||||
- $formkit: select
|
||||
name: position
|
||||
label: 所在位置
|
||||
|
||||
@@ -14,7 +14,13 @@
|
||||
<i class="i-pixelarticons-github"></i>
|
||||
</span>
|
||||
|
||||
<th:block th:with="items=${theme.config.activity.activity_items}">
|
||||
<th:block
|
||||
th:with="items=${theme.config.activity.activity_items},
|
||||
primaryMenu=${menuFinder.getPrimary()},
|
||||
archiveMenuItem=${primaryMenu != null and primaryMenu.menuItems != null and !#lists.isEmpty(primaryMenu.menuItems) ? primaryMenu.menuItems.^[status != null and !#strings.isEmpty(status.href) and ((spec != null and spec.href == '/archives') or status.href == '/archives' or status.displayName == 'Archives' or status.displayName == '归档')] : null},
|
||||
archiveActivityItem=${items != null and !#lists.isEmpty(items) ? items.^[type == 'archive' or key == 'archive'] : null},
|
||||
activityArchiveHref=${archiveMenuItem != null and archiveMenuItem.status != null and !#strings.isEmpty(archiveMenuItem.status.href) ? archiveMenuItem.status.href : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.url) ? archiveActivityItem.url : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.href) ? archiveActivityItem.href : '/archives'))}"
|
||||
>
|
||||
<div class="devcm-activity__group devcm-activity__group--up">
|
||||
<th:block th:if="${items != null and !#lists.isEmpty(items)}">
|
||||
<th:block
|
||||
@@ -22,7 +28,8 @@
|
||||
th:with="placement=${#strings.isEmpty(item.position) ? 'up' : item.position},
|
||||
itemType=${!#strings.isEmpty(item.type) ? item.type : (!#strings.isEmpty(item.key) ? item.key : 'custom')},
|
||||
entryAction=${itemType == 'search' or item.action == 'search' ? 'search' : 'link'},
|
||||
entryHref=${entryAction == 'search' ? '#' : (!#strings.isEmpty(item.url) ? item.url : (!#strings.isEmpty(item.href) ? item.href : '#'))},
|
||||
entryConfiguredHref=${!#strings.isEmpty(item.url) ? item.url : (!#strings.isEmpty(item.href) ? item.href : '#')},
|
||||
entryHref=${entryAction == 'search' ? '#' : (itemType == 'archive' ? activityArchiveHref : entryConfiguredHref)},
|
||||
entryLabel=${!#strings.isEmpty(item.label) ? item.label : (!#strings.isEmpty(item.labelKey) ? #messages.msg(item.labelKey) : #messages.msg('devcm.activity.link'))}"
|
||||
>
|
||||
<a
|
||||
@@ -95,7 +102,8 @@
|
||||
<a
|
||||
class="devcm-activity__button"
|
||||
th:classappend="${pageType == 'archive' or pageType == 'post'} ? ' devcm-activity__button--active' : ''"
|
||||
href="/archives"
|
||||
href="#"
|
||||
th:href="${activityArchiveHref}"
|
||||
th:title="#{devcm.activity.archive}"
|
||||
th:attr="data-label=#{devcm.activity.archive},aria-label=#{devcm.activity.archive}"
|
||||
>
|
||||
@@ -129,7 +137,8 @@
|
||||
th:with="placement=${#strings.isEmpty(item.position) ? 'up' : item.position},
|
||||
itemType=${!#strings.isEmpty(item.type) ? item.type : (!#strings.isEmpty(item.key) ? item.key : 'custom')},
|
||||
entryAction=${itemType == 'search' or item.action == 'search' ? 'search' : 'link'},
|
||||
entryHref=${entryAction == 'search' ? '#' : (!#strings.isEmpty(item.url) ? item.url : (!#strings.isEmpty(item.href) ? item.href : '#'))},
|
||||
entryConfiguredHref=${!#strings.isEmpty(item.url) ? item.url : (!#strings.isEmpty(item.href) ? item.href : '#')},
|
||||
entryHref=${entryAction == 'search' ? '#' : (itemType == 'archive' ? activityArchiveHref : entryConfiguredHref)},
|
||||
entryLabel=${!#strings.isEmpty(item.label) ? item.label : (!#strings.isEmpty(item.labelKey) ? #messages.msg(item.labelKey) : #messages.msg('devcm.activity.link'))}"
|
||||
>
|
||||
<a
|
||||
|
||||
+8
-2
@@ -8,12 +8,18 @@
|
||||
<div class="devcm-editor-tabs">
|
||||
<div
|
||||
class="devcm-editor-tab devcm-editor-tab--active"
|
||||
th:with="postTabName=${!#strings.isEmpty(post.spec.slug) ? post.spec.slug : post.metadata.name}"
|
||||
th:with="postTabBaseName=${!#strings.isEmpty(post.spec.slug) ? post.spec.slug : post.metadata.name},
|
||||
postTabName=${#strings.endsWith(postTabBaseName, '.md') ? postTabBaseName : postTabBaseName + '.md'},
|
||||
primaryMenu=${menuFinder.getPrimary()},
|
||||
archiveMenuItem=${primaryMenu != null and primaryMenu.menuItems != null and !#lists.isEmpty(primaryMenu.menuItems) ? primaryMenu.menuItems.^[status != null and !#strings.isEmpty(status.href) and ((spec != null and spec.href == '/archives') or status.href == '/archives' or status.displayName == 'Archives' or status.displayName == '归档')] : null},
|
||||
archiveActivityItem=${theme.config.activity.activity_items != null and !#lists.isEmpty(theme.config.activity.activity_items) ? theme.config.activity.activity_items.^[type == 'archive' or key == 'archive'] : null},
|
||||
postCloseHref=${archiveMenuItem != null and archiveMenuItem.status != null and !#strings.isEmpty(archiveMenuItem.status.href) ? archiveMenuItem.status.href : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.url) ? archiveActivityItem.url : (archiveActivityItem != null and !#strings.isEmpty(archiveActivityItem.href) ? archiveActivityItem.href : '/archives'))}"
|
||||
>
|
||||
<span th:text="${postTabName}">post</span>
|
||||
<a
|
||||
class="devcm-editor-tab__close"
|
||||
href="/archives"
|
||||
href="#"
|
||||
th:href="${postCloseHref}"
|
||||
th:aria-label="#{devcm.action.closePostTab}"
|
||||
th:title="#{devcm.action.closePostTab}"
|
||||
>×</a
|
||||
|
||||
在新议题中引用
屏蔽一个用户