Skip to content

Commit

Permalink
Hoist farmOS docs to the root level.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaehring committed Dec 17, 2021
1 parent 6c22954 commit 19c2e89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
12 changes: 11 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,18 @@ const fromSourceConfig = config => {
}, nav);
};

// Pulls sources with a key of '/' up to the root-level navigation.
const hoistRoot = nav => ({
...nav,
children: nav.children.flatMap((child) => {
if (child.key === '/') return child.children;
return child;
// Removes the "Home" route from nav.
}).filter(({ page }) => !page || page.pathname !== '/'),
});

exports.onPostBootstrap = function cacheSourceData() {
const navigation = fromSourceConfig(sources);
const navigation = hoistRoot(fromSourceConfig(sources));
const json = JSON.stringify({ sources, navigation });
const jsonPath = path.join(__dirname, '.cache/__farmOS__source_data.json');
fs.writeFileSync(jsonPath, json);
Expand Down
6 changes: 3 additions & 3 deletions source-repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = [
{
name: 'farmOS',
title: 'farmOS 2.x Docs',
baseURI: '/docs',
baseURI: '/',
mkdocs: 'mkdocs.yml',
remote: 'https://github.com/farmOS/farmOS.git',
branch: '2.x',
Expand All @@ -11,7 +11,7 @@ module.exports = [
{
name: 'farmOS.js',
title: 'farmOS.js',
parentPath: '/docs/development',
parentPath: '/development',
baseURI: '/farmos-js',
mkdocs: 'docs/config.yml',
remote: 'https://github.com/farmOS/farmOS.js.git',
Expand All @@ -21,7 +21,7 @@ module.exports = [
{
name: 'farmOS.py',
title: 'farmOS.py',
parentPath: '/docs/development',
parentPath: '/development',
baseURI: '/farmos-py',
mkdocs: 'docs/config.yml',
remote: 'https://github.com/farmOS/farmOS.py.git',
Expand Down
2 changes: 1 addition & 1 deletion src/content/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ nav:
- Supporters: community/supporters.md
- Press: community/press.md
- Trademark: community/trademark.md
- Donate: donate.md
- Donate: donate.md

0 comments on commit 19c2e89

Please sign in to comment.