Skip to content

Commit

Permalink
Fix path checking logic (#503)
Browse files Browse the repository at this point in the history
`categoryPagePathForDir` considers a page called `introduction.mdx` the
same as the root of the containing directory. This is incorrect, and
this equivalence actually depends on whether a redirect exists between
the `introduction` page and the directory root.
  • Loading branch information
ptgott authored Nov 19, 2024
1 parent 3d636a9 commit 4b5cb28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
8 changes: 2 additions & 6 deletions server/config-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,13 @@ const correspondingFileExistsForURL = (
// Each URL in the docs config begins at docs/pages within a given version's
// content directory. Get the MDX file for a given URL and check if it
// exists in the filesystem. URL paths must point to (a) an MDX file with
// the same name as the final path segment; (b) a file named "index.mdx"; or
// (c) a file named "introduction.mdx".
// the same name as the final path segment; or (b) a file named "index.mdx".
const mdxPath = urlpath.replace(/\/$/, ".mdx");
const docsPagePath = resolve(join(dirRoot, mdxPath));

const indexPath = resolve(join(dirRoot, urlpath + "index.mdx"));

const introPath = resolve(join(dirRoot, urlpath + "introduction.mdx"));

if (
[docsPagePath, indexPath, introPath].find((p) => {
[docsPagePath, indexPath].find((p) => {
return fs.existsSync(p);
}) == undefined
) {
Expand Down
5 changes: 0 additions & 5 deletions uvu-tests/config-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ Suite("Ensures that URLs correspond to docs pages", () => {
icon: "bolt",
title: "About",
entries: [
{
title: "Introduction",
slug: "/about/",
forScopes: ["oss"],
},
{
title: "Projects",
slug: "/about/projects/",
Expand Down

0 comments on commit 4b5cb28

Please sign in to comment.