Skip to content

Instantly share code, notes, and snippets.

@cameronhotchkies
Created April 17, 2020 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cameronhotchkies/ba3a5f6a48298f2090d8d1c87a69860b to your computer and use it in GitHub Desktop.
Save cameronhotchkies/ba3a5f6a48298f2090d8d1c87a69860b to your computer and use it in GitHub Desktop.
Dynamic sidebar in Docusaurus
const fs = require('fs');
const autoIndexRegex = /^\d*\-.*\.md$/;
items = fs.readdirSync('docs/standards');
const detectedPages = items.filter(filename => {
return autoIndexRegex.test(filename)
});
// TODO: read front matter to verify
const detectedDocuments = detectedPages.map(filename => {
const docName = filename.slice(0, -3);
return {
type: 'doc',
id: `standards/${docName}`
}
})
const publishedStandards = detectedDocuments;
module.exports = {
// Original
docs: {
DocusaurusX: ['doc1', 'doc2', 'doc3'],
FeaturesY: ['mdx'],
},
//
'standards': {
'Engineering Standards': ['standards/standards0'].concat(publishedStandards),
Proposals: ['standards/proposed0'],
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment