Files
docs/versioned_docs/version-2.13/developer-guide/theme/finder-apis/menu.md
Ryan Wang de60c8a3fd chore: improve importing markdown file name (#368)
为被导入的 Markdown 片段文件名添加 `_`,防止为其生成页面。比如:https://docs.halo.run/developer-guide/theme/vo/ThemeVo

参考文档:https://docusaurus.io/docs/2.x/markdown-features/react#importing-markdown

/kind improvement

```release-note
None
```
2024-06-03 06:35:44 +00:00

1.3 KiB

title, description
title description
导航菜单 导航菜单 - MenuFinder

import MenuItemVo from "../vo/_MenuItemVo.md" import MenuVo from "../vo/_MenuVo.md"

getByName(name)

menuFinder.getByName(name)

描述

根据 metadata.name 获取菜单。

参数

  1. name:string - 菜单的唯一标识 metadata.name

返回值

#MenuVo

示例

<div th:with="menu = ${menuFinder.getByName('menu-foo')}">
  <ul th:with="menuItems = ${menu.menuItems}">
    <li th:each="menuItem : ${menuItems}">
      <a
        th:href="@{${menuItem.status.href}}"
        th:text="${menuItem.status.displayName}"
        th:target="${menuItem.spec.target?.value}"
      >
      </a>
    </li>
  </ul>
</div>

getPrimary()

menuFinder.getPrimary()

描述

获取主菜单。

参数

返回值

#MenuVo

示例

<div th:with="menu = ${menuFinder.getPrimary()}">
  <ul th:with="menuItems = ${menu.menuItems}">
    <li th:each="menuItem : ${menuItems}">
      <a
        th:href="@{${menuItem.status.href}}"
        th:text="${menuItem.status.displayName}"
        th:target="${menuItem.spec.target?.value}"
      >
      </a>
    </li>
  </ul>
</div>

类型定义

MenuVo

MenuItemVo