Page Conventions
Build page tree with file-system based routing
Overview
This is a shared convention for organizing your pages, should be followed by all built-in file-system based sources including Contentlayer and Fumadocs MDX.
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.
By default, pages are sorted with String.localeCompare{:js}
.
The index.mdx
file is always ordered at the top.
Meta
You can also customize the folder name, order of pages, or add a separator by
creating a meta.json
in the folder.
Multiple Page Trees
Adding a root
property in meta can mark your folder as a root folder.
The nearest root folder of current page will be used as the root of page tree.
Separator
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 with the icon
property in your frontmatter or meta file.
Internationalization
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.
It is same for meta files, you have to add .{locale}
to the file name like 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