From e2f6fab9f0e751aa9a6e5b257898bfddd2471149 Mon Sep 17 00:00:00 2001 From: "fryorcraken.eth" Date: Mon, 19 Feb 2024 15:01:44 +1100 Subject: [PATCH] Autogenerate sidebar Also add intro to research section --- docs/research/index.md | 10 ++++++++++ fetch-content.js | 18 +++++++++++++----- sidebars.js | 14 +++----------- 3 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 docs/research/index.md diff --git a/docs/research/index.md b/docs/research/index.md new file mode 100644 index 0000000..a9faead --- /dev/null +++ b/docs/research/index.md @@ -0,0 +1,10 @@ +--- +title: Research +hide_table_of_contents: true +sidebar_position: 1 +--- + +**Research and Studies**: protocol simulations and theoretical analysis to support the design +of Waku protocols. The protocol definitions can be found on the [Vac RFC](https://rfc.vac.dev/) website. + +**Benchmarks**: Results of implementations and engineering related benchmarks for Waku clients. diff --git a/fetch-content.js b/fetch-content.js index 0acef6e..2e082de 100644 --- a/fetch-content.js +++ b/fetch-content.js @@ -63,17 +63,25 @@ const repositories = [ { baseUrl: 'https://api.github.com/repos/waku-org/nwaku/contents/docs/benchmarks', baseSavePath: '/docs/research/benchmarks/', - prefixToRemove: 'docs/benchmarks/' + prefixToRemove: "docs/benchmarks/", + categoryFileContent: "{ \"label\": \"Benchmarks\", \"collapsed\": false }" }, { baseUrl: 'https://api.github.com/repos/waku-org/research/contents/docs', baseSavePath: '/docs/research/research-and-studies/', - prefixToRemove: 'docs/' + prefixToRemove: "docs/", + categoryFileContent: "{ \"label\": \"Research and Studies\", \"collapsed\": false }" } ]; -fs.rmSync('docs/research/', { recursive: true, force: true }); +repositories.forEach(repo => { + fs.rmSync(path.join(__dirname, repo.baseSavePath), { recursive: true, force: true }); +}); repositories.forEach(repo => { - fetchDirectoryContents(repo.baseUrl, repo.baseSavePath, repo.prefixToRemove); -}); \ No newline at end of file + fetchDirectoryContents(repo.baseUrl, repo.baseSavePath, repo.prefixToRemove, repo.categoryFileContent).then(() => { + const dir = path.join(__dirname, repo.baseSavePath); + fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(path.join(dir, "_category_.json"), repo.categoryFileContent); + }); +}); diff --git a/sidebars.js b/sidebars.js index 2ceaf18..5be6b78 100644 --- a/sidebars.js +++ b/sidebars.js @@ -87,18 +87,10 @@ const sidebars = { ], research: [ { - type: "category", - label: "Research and Studies", - collapsed: false, - items: ["research/research-and-studies/incentivisation"], - }, - { - type: "category", - label: "Nwaku Benchmarks", - collapsed: false, - items: ["research/benchmarks/postgres-adoption"], + type: 'autogenerated', + dirName: 'research', // '.' means the current docs folder }, ], }; -module.exports = sidebars; \ No newline at end of file +module.exports = sidebars;