mirror of
https://github.com/Lissy93/dashy.git
synced 2026-07-30 19:15:59 -04:00
68 lines
1.9 KiB
JavaScript
68 lines
1.9 KiB
JavaScript
/**
|
|
* Creating a sidebar enables you to:
|
|
- create an ordered group of docs
|
|
- render a sidebar for each doc of that group
|
|
- provide next/previous navigation
|
|
|
|
The sidebars can be generated from the filesystem, or explicitly defined here.
|
|
|
|
Create as many sidebars as you want.
|
|
*/
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const DOCS_DIR = path.join(__dirname, 'docs');
|
|
|
|
const labelFor = (id) => id
|
|
.split('-')
|
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
.join(' ');
|
|
|
|
// Docs with a same-named folder of sub-pages become expandable categories (readme stubs don't count)
|
|
const withSubPages = (id) => {
|
|
if (typeof id !== 'string') return id;
|
|
const dir = path.join(DOCS_DIR, id);
|
|
const hasSubPages = fs.existsSync(dir) && fs.readdirSync(dir)
|
|
.some((file) => /\.mdx?$/i.test(file) && !/^readme\.mdx?$/i.test(file));
|
|
if (!hasSubPages) return id;
|
|
return {
|
|
type: 'category',
|
|
label: labelFor(id),
|
|
link: { type: 'doc', id },
|
|
items: [{ type: 'autogenerated', dirName: id }],
|
|
};
|
|
};
|
|
|
|
module.exports = {
|
|
// tutorialSidebar: [{type: 'autogenerated', dirName: '.'}],
|
|
|
|
dashySidebar: [
|
|
{
|
|
type: 'category',
|
|
label: 'Running Dashy',
|
|
items: ['quick-start', 'deployment', 'configuring', 'management', 'troubleshooting'].map(withSubPages),
|
|
},
|
|
{
|
|
type: 'category',
|
|
label: 'Feature Docs',
|
|
items: [
|
|
'icons', 'widgets', 'theming', 'status-indicators', 'authentication',
|
|
'searching', 'alternate-views',
|
|
'multi-language-support', 'backup-restore', 'pages-and-sections',
|
|
].map(withSubPages),
|
|
},
|
|
{
|
|
type: 'category',
|
|
label: 'Community',
|
|
items: ['showcase', 'contributing', 'developing', 'development-guides'].map(withSubPages),
|
|
},
|
|
{
|
|
type: 'category',
|
|
label: 'Misc',
|
|
items: ['privacy', 'credits', 'license', 'release-workflow'].map(withSubPages),
|
|
},
|
|
],
|
|
|
|
};
|