docusaurus plugin - what it needs to do
In short:
- Import docs and blogs from source directory
- Read the files
- Parse the front matters of said files
- Add appropriate
title
frontmatter - Alter obsidian backlinks to appropriate docusaurus links
- Write the files
- Create the tags dictionary ( key: id, value: {name: doc name, tags: (all, including nested)} )
- Create and place the sidebar file TagMap and enhanced sidebar
- Load the files in destination directory
Notes :
const glob = require('glob');
const matter = require('gray-matter');
function getDocs(srcDir) {
// const files = glob.sync("../../docs/**/*.md"); // Adjust path as necessary
const files = glob.sync(path.join(srcDir, "/**/*.md"))
return files.map(file => {
const content = fs.readFileSync(file, 'utf8');
const metadata = matter(content);
return {
...metadata.data,
path: file,
};
});
}
- 🔺 Change glob to the official one ✅ 2024-07-22 (glob turned out better)