From 99d658827c5cc3c57b33af45542d224727e007cf Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Fri, 20 Sep 2024 22:21:05 +0200 Subject: [PATCH] Website: fixup keep autolinked local references --- website/src/plugins.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/website/src/plugins.ts b/website/src/plugins.ts index 18a7bf6..4f62ffc 100644 --- a/website/src/plugins.ts +++ b/website/src/plugins.ts @@ -93,15 +93,15 @@ export function replaceComponents() { }; } if (["a"].includes(node.tagName) && index !== undefined) { - // node, - // c: node.tagName, - // }); parent.children[index] = { type: "element", tagName: `a`, properties: { "data-link-md": true, - ...redirectNixpkgsManualAnchor(node.properties.href as string), + ...redirectNixpkgsManualAnchor( + node.properties.href as string, + !node.properties["data-autolinked"] as boolean + ), }, // Pass props here if needed children: node.children, }; @@ -110,7 +110,10 @@ export function replaceComponents() { }; } -function redirectNixpkgsManualAnchor(href: string) { +function redirectNixpkgsManualAnchor(href: string, transformLink: boolean) { + if (!transformLink) { + return { href }; + } if (href.startsWith("@docroot@")) { return { href: `https://nix.dev/manual/nix/latest/${href