Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/fixed-355-sync-sibling-docs-mdx-route.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- `scripts/sync-sibling-docs.ts` now strips `.mdx` as well as `.md` when
mapping a synced page to its `/docs/<project>/…` route, so links to pages
synced as MDX no longer resolve to `/docs/<project>/<page>.mdx`
(hivecommons/docs#355).
12 changes: 12 additions & 0 deletions scripts/sync-sibling-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ describe("rewriteLinks", () => {
);
});

it("strips .mdx as well as .md from a synced target's route", () => {
const mdx: ProjectSync = {
...spek,
files: [
{ source: "docs/guide.md", target: "guide.mdx", required: false },
],
};
expect(rewriteLinks("[g](docs/guide.md#top)", mdx)).toBe(
"[g](/docs/spektacular/guide#top)"
);
});

it("matches synced pages case-insensitively", () => {
expect(rewriteLinks("[kb](Docs/Knowledge-Base.MD)", spek)).toBe(
"[kb](/docs/spektacular/knowledge-base)"
Expand Down
2 changes: 1 addition & 1 deletion scripts/sync-sibling-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export function rewriteLinks(
for (const s of p.files) {
syncedRoutes.set(
s.source.toLowerCase(),
`/docs/${p.project}/${s.target.replace(/\.md$/i, "")}`
`/docs/${p.project}/${s.target.replace(/\.mdx?$/i, "")}`
);
}
const r = f ? fileRepo(p, f) : p;
Expand Down
Loading