Skip to content

Commit

Permalink
feat: adapt the target attribute of the menuitem (#56)
Browse files Browse the repository at this point in the history
适配 MenuItem 的 target 属性,支持设置菜单打开方式,参考:

- https://docs.halo.run/developer-guide/theme/finder-apis/menu
- halo-dev/halo#3072

注意,因为 target 属性是在 2.1.0 之后添加的,所以主题的 requires 设置为了 `>=2.1.0`。

/kind feature

```release-note
适配 Halo 菜单项打开方式的设置。
```
  • Loading branch information
ruibaby authored Mar 19, 2023
1 parent 8d0081f commit 9f2b374
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion templates/modules/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
class="text-gray-600 hover:text-blue-600 dark:text-slate-50 dark:hover:text-gray-300"
th:href="@{${menuItem.status.href}}"
th:text="${menuItem.status.displayName}"
th:target="${menuItem.spec.target?.value}"
></a>
<ul
th:if="${not #lists.isEmpty(menuItem.children)}"
Expand All @@ -51,6 +52,7 @@
class="h-full w-full truncate px-4 py-2 text-gray-600 hover:text-blue-600 dark:text-slate-50 dark:hover:text-gray-300"
th:href="@{${childMenuItem.status.href}}"
th:text="${childMenuItem.status.displayName}"
th:target="${childMenuItem.spec.target?.value}"
></a>
</li>
</ul>
Expand Down Expand Up @@ -189,7 +191,7 @@ <h2 class="text-sm font-medium text-gray-600 dark:text-slate-300">菜单</h2>
<nav class="mt-6">
<ul class="-my-2 divide-y divide-gray-100 text-sm text-gray-800 dark:divide-slate-800 dark:text-slate-100">
<li th:each="menuItem : ${menu.menuItems}">
<a class="flex items-center justify-between gap-1 py-2" th:href="@{${menuItem.status.href}}">
<a class="flex items-center justify-between gap-1 py-2" th:href="@{${menuItem.status.href}}" th:target="${menuItem.spec.target?.value}">
<span th:text="${menuItem.status.displayName}"></span>
</a>
<ul class="divide-y divide-gray-100 dark:divide-slate-800" th:if="${not #lists.isEmpty(menuItem.children)}">
Expand All @@ -198,6 +200,7 @@ <h2 class="text-sm font-medium text-gray-600 dark:text-slate-300">菜单</h2>
class="h-full w-full truncate px-4 py-2 text-gray-600 dark:text-slate-200"
th:href="@{${childMenuItem.status.href}}"
th:text="${childMenuItem.status.displayName}"
th:target="${childMenuItem.spec.target?.value}"
></a>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ spec:
settingName: "theme-earth-setting"
configMapName: "theme-earth-configMap"
version: 1.2.0
require: 2.0.0
require: ">=2.1.0"

0 comments on commit 9f2b374

Please sign in to comment.