Organizing Pages
Organize documents with file-system based routing
Overview
This is a shared convention for organizing your pages, followed by all file-system based content sources including Adalt MDX.
File
A MDX or Markdown file.
Frontmatter
By default, it includes:
name | description |
---|---|
title | The title of page |
description | The description of page |
icon | The name of icon, see Icons |
full | Fill all available space on the page (Adalt UI) |
You may extend your content source to add additional properties.
Folder
Organize multiple pages. When not specified, the display name will be generated from its folder name.
Pages are sorted alphabetically, except for index.mdx
which is always ordered at the top.
To customise folders, see Meta file.
Folder Group
By default, putting a file into folder will change its slugs and generated page URL. You can use folder group to add a folder without impacting the slugs of child files.
To create a folder group, wrap the folder name in parentheses.
Meta
Customize a folder by creating a meta.json
file in the folder.
Display Name
Icon
Specify an icon name for folder with the icon
property, see Icons.
Pages
Control the order of items.
When a meta file is present, items are not included unless you have explicitly added them to pages
.
Path
The items of pages
property can be a relative path to a page or folder. File extensions are not required.
Open by Default
Force to open the folder by default.
Separator
You can define a separator in meta by adding a item surrounded with ---
.
Rest
Add a Rest (...
) item to automatically add and sort remaining page items.
Note
Index pages won't be included, you must specify the order of index
.
Except
In conjunction with the Rest item (...
), you can use !name
to exclude an item from the rest.
Extract
You can extract the items from a folder with ...folder_name
.
Link
Use the syntax [Text](url)
to insert links.
You can add an icon too.
Icons
Since Adalt doesn't include an icon library, you have to convert the icon names to JSX elements so that it can be rendered as a component.
For built-in content sources like Adalt MDX, you can use the icon
handler from Source API.
Multiple Page Trees
Adding a root
property in meta file can mark your folder as a root.
When the user is browsing a page under a root folder, only the child items of the folder will be visible.
For example, when you are in a root folder called core
, the other folders (e.g. ui
) are not shown on the sidebar (and other navigation elements).
To allow users switching between different roots, implement a component that navigates to a page under the root folders. On Adalt UI, this is available via the Root Toggle component.
By default, index pages are not considered as the pages "under" a folder, you must specify them in the pages
property.
Internationalization
You can create a localized page for specific language by adding .{locale}
to your file name. Pages can't be language-specific, you must create a page for default
locale in order to have its localized version.
This works for meta files too, you can 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 add locale code to file name.
Example
Assume your default language is en
.
Name | |
---|---|
file.mdx | Correct |
file.cn.mdx | Correct |
file.en.mdx | Default locale doesn't need a locale code |
components.cn.mdx | Pages can't be language-specific |
Last updated on