doc-docusaurus-manual/docs/writing-content/config-the-docs-group.mdx
2025-04-01 09:55:25 +07:00

69 lines
2.8 KiB
Plaintext

---
sidebar_position: 4
---
# Config the docs group
This guide will help you organize and configure your folder much more easy to navigating. For example, you can create a set of button like on the folder description page.
import DocCardList from '@theme/DocCardList';
<DocCardList />
## Add config file
On the previous page, we created a folder structure like this:
```
docs/
├── my-folder/
│ ├── doc1.md
│ ├── doc2.md
...
```
Now add a `_category_.json` file to the `my-folder` directory. The `_category_.json` file defines the label and position of the folder in the sidebar.
```
docs/
├── my-folder/
│ ├── _category_.json
│ ├── doc1.md
│ ├── doc2.md
...
```
## Edit config file
Example: `docs/my-folder/_category_.json`
```json
{
"position": 2.5,
"label": "My Folder",
"collapsible": true,
"collapsed": false,
"className": "red",
"link": {
"type": "generated-index",
"title": "Tutorial overview"
},
"customProps": {
"description": "This description can be used in the swizzled DocCard"
}
}
```
| Field | Description | Example Value |
|-----------------|-------------------------------------------------------------------------------------------------|-----------------------------------|
| `position` | Determines the order of the folder in the sidebar. Lower values appear higher. | `2.5` |
| `label` | The name of the folder as it appears in the sidebar. | `"Tutorial"` |
| `collapsible` | Specifies if the folder in the sidebar can be collapsed. | `true` or `false` |
| `collapsed` | Sets whether the folder is collapsed by default when the page loads. | `true` or `false` |
| `className` | Adds a custom CSS class to the folder for styling purposes. | `"red"` |
| `link` | Configures a link for the folder. Typically used to generate an index page for the folder. | `{ "type": "generated-index", "title": "Tutorial overview" }` |
| `customProps` | Custom properties that can be used in swizzled components, such as descriptions or metadata. | `{ "description": "This description can be used in the swizzled DocCard" }` |
:::info
All fields in `_category_.json` are **optional**. If a field is not provided, Docusaurus will use default behavior or omit the feature.
:::
Now, on your site, you can click on **My Folder** in the sidebar to view its contents or navigate to the generated index page if configured.