Skip to content

Commit

Permalink
Get tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgott committed Oct 17, 2024
1 parent 59d05e1 commit 14f90bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 57 deletions.
5 changes: 3 additions & 2 deletions server/pages-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ const categoryPagePathForDir = (fs, dirPath) => {
const innerExists = fs.existsSync(innerCategoryPage);

if (outerExists && innerExists) {
// Docusaurus only accepts a category page within its associated directory.
return innerCategoryPage;
throw new Error(
`cannot generate the docs navigation sidebar due to an ambiguous category page: remove ${outerCategoryPage} and keep ${innerCategoryPage}`
);
}
if (outerExists) {
throw new Error(
Expand Down
55 changes: 0 additions & 55 deletions uvu-tests/config-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,61 +370,6 @@ title: Get Started with DB RBAC
assert.equal(actual, expected);
});

Suite(
"allows category pages in the same directory as the associated subdirectory",
() => {
const files = {
"/docs/pages/database-access/guides.mdx": `---
title: Database Access Guides
---`,
"/docs/pages/database-access/guides/postgres.mdx": `---
title: Postgres Guide
---`,
"/docs/pages/database-access/guides/mysql.mdx": `---
title: MySQL Guide
---`,
"/docs/pages/database-access/guides/rbac.mdx": `---
title: Database Access RBAC
---`,
"/docs/pages/database-access/guides/rbac/get-started.mdx": `---
title: Get Started with DB RBAC
---`,
};

const expected = [
{
title: "Database Access Guides",
slug: "/database-access/guides/",
entries: [
{
title: "Database Access RBAC",
slug: "/database-access/guides/rbac/",
entries: [
{
title: "Get Started with DB RBAC",
slug: "/database-access/guides/rbac/get-started/",
},
],
},
{
title: "MySQL Guide",
slug: "/database-access/guides/mysql/",
},
{
title: "Postgres Guide",
slug: "/database-access/guides/postgres/",
},
],
},
];

const vol = Volume.fromJSON(files);
const fs = createFsFromVolume(vol);
let actual = generateNavPaths(fs, "/docs/pages/database-access");
assert.equal(actual, expected);
}
);

Suite("generates four levels of the sidebar", () => {
const files = {
"/docs/pages/database-access/guides/guides.mdx": `---
Expand Down

0 comments on commit 14f90bb

Please sign in to comment.