导航文件组合
如果您想从不同的文件组成一个导航列表,可能是为了重用这些列表,组织它们以便由不同的人维护,或者简单地将它们分开,您可以使用 include
指令。
将一个导航文件包含到另一个中
可以使用 AsciiDoc include 指令将一个导航文件包含到另一个导航文件中。include
指令的目标必须是一个被 Antora 分类的文件,这意味着它必须是一个页面或一个部分。(Antora 不会对位于模块根目录或 modules 文件夹中的文件进行分类)。
让我们假设其中一个导航列表定义在文件 modules/ROOT/partials/getting-started.adoc
中。
Example 1. Example 1. modules/ROOT/partials/getting-started.adoc
.Getting Started
* xref:download.adoc[]
* xref:install.adoc[]
* xref:run.adoc[]
您可以按以下方式将此部分导航文件包含到主导航文件 modules/ROOT/nav.adoc
中:
Example 2. Example 2. modules/ROOT/nav.adoc
.Overview
* xref:index.adoc[]
* xref:contribute.adoc[]
Unresolved include directive in modules/navigation/pages/composeNavigationFiles.adoc - include::partial$getting-started.adoc[]
Getting Started
列表将从部分文件中读取,并包含在 Overview
列表之后的导航中。
包含一个嵌套列表
在某些情况下,您不确定部分列表将包含在导航树中的哪个位置,也不能假设它是在顶层添加的。您想要的是包含中的导航列表比当前列表项低一级。
为了完成这种布局,将包含的列表包装在一个开放的块中:
* xref:parent.adoc[]
+
--
Unresolved include directive in modules/navigation/pages/composeNavigationFiles.adoc - include::partial$children.adoc[]
--
Antora 将识别这种关系,并将包含的列表融合为它所附加的列表项的子列表。( open
块容器被丢弃)。
假设 getting started
项在 modules/ROOT/partials/getting-started.adoc
文件中作为匿名列表定义。
Example 3. Example 3. modules/ROOT/partials/getting-started.adoc
* xref:download.adoc[]
* xref:install.adoc[]
* xref:run.adoc[]
现在我们可以将该列表作为导航文件中 Getting Started 项的子列表包含进来。
Example 4. Example 4. modules/ROOT/nav.adoc
* xref:index.adoc[]
* xref:contribute.adoc[]
* Getting Started
+
--
Unresolved include directive in modules/navigation/pages/composeNavigationFiles.adoc - include::partial$getting-started.adoc[]
--
* xref:reference.adoc[]
部分文件中的列表项将是 Getting Started
项的子项。