Page Tree Builder
Build Page Tree with File System or your own content source
Usage
Create a builder instance, and pass your pages and meta files as options.
Multiple Trees
You can build multiple trees with the same builder instance.
Internationalization
You can also build internationalized page tree with the buildI18n
method, it
returns a language-to-page-tree map.
Pages Structure
Shared conventions for structuring your pages.
File
By default, it uses MDX and supports title
and
description
frontmatter:
You may edit the configuration file to add additional properties.
Folder
You can use folders to organize multiple pages, the uppercased name of the folder will be used as the display name.
Meta
You can also customize the folder name, order of pages, or adding a separator by
creating a meta.json
in the folder.
By default, pages are sorted by String.localeCompare
.
Separator
As you see, you can define a separator in meta by adding a item surrounded by
---
.
Rest
Tired to specify the order of every single page in meta.json
? You can use
...
to automatically add and sort remaining items.
Index pages won't be included, you must specify the order of index
.
Extract
You can extract the items from a folder with ...folder_name
.
Icons
It is supported to have custom icons for a page or a folder. Add an icon
property to the frontmatter or meta.json
, and configure icon handler via
resolveIcon
option.
With Locale
You can create a page for specific language by adding .{locale}
to your MDX
file name. Pages can't be language-specific, you must create a page for default
locale in order to have its localized version.
For meta files, you have to add -{locale}
to the file name instead (e.g.
meta-cn.json
).
If it's the default language, just leave it empty like get-started.mdx
. Do
not use add locale code to file name.
Assume your default language is en
.
Name | |
---|---|
meta.json | Allowed |
meta-cn.json | Allowed |
meta-en.json | Not Allowed |
get-started.mdx | Allowed |
get-started.cn.mdx | Allowed |
get-started.en.mdx | Not Allowed |
components.cn.mdx | Not Allowed |
Last updated on