章节、页面和文件夹
章节、页面和文件夹
在 docs.yml 中组织您的侧边栏导航结构
章节、页面和文件夹
在 docs.yml 中组织您的侧边栏导航结构
docs.yml 中的 navigation 键定义了您的侧边栏结构。通过组合章节、页面和文件夹来构建它。
章节在左侧导航栏中组织您的文档。每个章节都有一个名称和一个 contents 列表,可以包括页面、文件夹或嵌套章节。
章节可以嵌套以创建多级导航层次结构。

要为章节添加概述页面,添加一个指向 .mdx 文件的 path 属性。
创建一个 .md 或 .mdx 文件,然后在章节的 contents 中添加一个包含文件路径的 page 条目。
添加一个指向目录的 folder 条目。Fern 会自动发现所有 .md 和 .mdx 文件并将它们添加到导航中。
对于文件夹中的页面,Fern 自动:
index.mdx 或 index.md 文件作为章节概述页面(不区分大小写)使用这些选项自定义文件夹行为:
为此文件夹章节显示的标题。如果未提供,则使用文件夹名称。
确定文件夹内的页面和章节标题如何生成。默认情况下(filename),标题从文件名生成。设置为 frontmatter 以使用每个文件 frontmatter 中的 title 字段(如果未设置则回退到文件名)。此单个文件夹设置会覆盖全局的 settings.folder-title-source 值。
覆盖文件夹自动生成的 URL 别名。
从 URL 路径中省略文件夹,因此页面显示在父级别。
在页面 frontmatter 中设置以控制文件夹内的排序。具有 position 的页面首先出现(按数字排序),然后是其余的按字母顺序排列。
要隐藏页面、文件夹或章节,添加 hidden: true。隐藏的内容(包括文件夹内的所有页面)仍可通过直接 URL 访问,但会从搜索中排除且不会被索引。
在页面、章节或文件夹上设置可用性徽章。选项有:stable、generally-available、in-development、pre-release、deprecated 或 beta。
页面从其父章节或文件夹继承可用性,除非被以下覆盖:
docs.yml 中的单个页面 availability 设置(如下所示)docs.yml 可用性设置如果您有不同版本的文档,章节、文件夹和页面可用性应在定义每个版本导航结构的 .yml 文件中设置。
默认情况下,章节和文件夹是展开的且不可折叠。使用 collapsed 属性控制它们在页面加载时在侧边栏中的显示方式。
使用 icon 键为章节、页面和文件夹添加图标。
Icons can be in three formats:
fa-solid fa-rocket. Pro and Brand Icons from Font Awesome are supported../assets/icons/my-icon.svg or ../assets/icons/my-icon.png). Paths are relative to the YAML file where the icon is referenced (e.g., docs.yml). For example, if you set an icon in fern/products/my-product.yml, the path ./assets/icon.svg resolves to fern/products/assets/icon.svg. If you set it in fern/docs.yml, the same path resolves to fern/assets/icon.svg."<svg>...</svg>").您可以通过以下配置在侧边栏导航中添加指向外部页面的链接:

Control where links open with the target property. Available for product, tab, navbar, and page links. For typical documentation sites, links can open in the same tab (_self) or new tab (_blank). For documentation embedded in a dashboard or iframe, links can open in the parent frame (_parent) or topmost frame (_top).