docs: refactor API documentation (#5219)

* Refactor plugin-docs documentation

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Refactor theme-configuration

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Refactor plugin-blog docs

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fix link

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* plugin-pages

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Minor change

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Interchange table columns

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fixes

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Minor improvements

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fix hash link

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Move blog front matter to API

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Add more blog documentation

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Update blog.md

* Update blog.md

* Update blog.md

* Update website/docs/blog.md

Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
Joshua Chen 2021-08-04 22:35:17 +08:00 committed by GitHub
parent 2c0b82e7ab
commit c603056f66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 686 additions and 469 deletions

View file

@ -22,9 +22,8 @@ module.exports = {
'@docusaurus/preset-classic',
{
docs: {
// highlight-start
// highlight-next-line
sidebarPath: require.resolve('./sidebars.js'),
// highlight-end
},
},
],
@ -334,9 +333,30 @@ module.exports = {
#### Collapsible categories {#collapsible-categories}
By default, categories are collapsible and collapsed.
We support the option to expand/collapse categories. Categories are collapsible by default, but you can disable collapsing with `collapsible: false`.
The docs plugin options allow to change these defaults globally:
```js title="sidebars.js"
module.exports = {
docs: [
{
type: 'category',
label: 'Guides',
items: [
'creating-pages',
{
type: 'category',
// highlight-next-line
collapsible: false,
label: 'Docs',
items: ['introduction', 'sidebar', 'markdown-features', 'versioning'],
},
],
},
],
};
```
To make all categories non-collapsible by default, set the `sidebarCollapsible` option in `plugin-docs` to `false`:
```js title="docusaurus.config.js"
module.exports = {
@ -345,10 +365,8 @@ module.exports = {
'@docusaurus/preset-classic',
{
docs: {
// highlight-start
sidebarCollapsible: true,
sidebarCollapsed: false,
// highlight-end
// highlight-next-line
sidebarCollapsible: false,
},
},
],
@ -356,9 +374,15 @@ module.exports = {
};
```
:::note
The option in `sidebars.js` takes precedence over plugin configuration, so it is possible to make certain categories collapsible when `sidebarCollapsible` is set to `false` globally.
:::
#### Expanded categories by default {#expanded-categories-by-default}
For docs that have collapsible categories, you may want more fine-grain control over certain categories. If you want specific categories to be always expanded, you can set `collapsed` to `false`:
Collapsible categories are collapsed by default. If you want them to be expanded on first render, you can set `collapsed` to `false`:
```js title="sidebars.js"
module.exports = {
@ -368,7 +392,7 @@ module.exports = {
{
type: 'category',
label: 'Docs',
collapsible: true,
// highlight-next-line
collapsed: false,
items: ['markdown-features', 'sidebar', 'versioning'],
},
@ -377,6 +401,30 @@ module.exports = {
};
```
Similar to `collapsible`, you can also set the global configuration `options.sidebarCollapsed` to `false`. Individual `collapsed` options in `sidebars.js` will still take precedence over this configuration.
```js title="docusaurus.config.js"
module.exports = {
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
// highlight-next-line
sidebarCollapsed: false,
},
},
],
],
};
```
:::caution
When a category has `collapsed: true` but `collapsible: false` (either through `sidebars.js` or through plugin configuration), the latter takes precedence and the category is still rendered as expanded.
:::
### Autogenerated: generate a sidebar {#sidebar-item-autogenerated}
Docusaurus can **create a sidebar automatically** from your **filesystem structure**: each folder creates a sidebar category.