Skip to content

Commit

Permalink
Try to implement
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgott committed Oct 17, 2024
1 parent 05c4ac0 commit 59d05e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
16 changes: 8 additions & 8 deletions server/pages-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ const sortByTitle = (a, b) => {
}
};

// categoryPagePathForDir looks for a category page at the same directory level
// as its associated directory OR within the associated directory. Throws an
// error if there is no category page for the directory.
// categoryPagePathForDir looks for a category page within the associated
// directory. Throws an error if there is no category page for the directory.
const categoryPagePathForDir = (fs, dirPath) => {
const { name } = parse(dirPath);

Expand All @@ -102,18 +101,19 @@ const categoryPagePathForDir = (fs, dirPath) => {
const innerExists = fs.existsSync(innerCategoryPage);

if (outerExists && innerExists) {
throw new Error(
`cannot generate the docs navigation sidebar due to an ambiguous category page: must have a page named ${outerCategoryPage} or ${innerCategoryPage}, not not both`
);
// Docusaurus only accepts a category page within its associated directory.
return innerCategoryPage;
}
if (outerExists) {
return outerCategoryPage;
throw new Error(
`subdirectory in generated sidebar section ${dirPath} needs a page called ${innerCategoryPage}. Move ${outerCategoryPage}`
);
}
if (innerExists) {
return innerCategoryPage;
}
throw new Error(
`subdirectory in generated sidebar section ${dirPath} has no category page ${innerCategoryPage} or ${outerCategoryPage}`
`subdirectory in generated sidebar section ${dirPath} has no category page ${innerCategoryPage}`
);
};

Expand Down
1 change: 0 additions & 1 deletion uvu-tests/config-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,6 @@ title: Deploying the Database Service on Kubernetes
assert.throws(
() => {
const actual = generateNavPaths(fs, "/docs/pages/database-access");
console.log(actual);
},
"database-access/deployment/deployment.mdx",
"database-access/deployment.mdx"
Expand Down

0 comments on commit 59d05e1

Please sign in to comment.