Configuration
Learn how to use Contentlayer with Next Docs
Next Docs has native support for Contentlayer, and provides default configuration with required MDX plugins.
Setup
- Edit your configuration.
Note: Configuration file shouldn't be imported anywhere.
- Build the Page Tree.
Pages Structure
All files are located in /content
and /content/docs
for documentation 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
---
.
Advanced
Next Docs Zeta also adds extra functionalities to Contentlayer, making it more convenient to use and straightforward.
Rest
Tired to specify the order of every single page in meta.json
? You can use
...
to automatically add and sort remaining items.
Note: 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
.
Adding 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.
Multiple Trees
You can build multiple trees by directly interacting with Pages Context API.
Last updated on