Merge pull request #354 from nix-community/johannes

Website: fixup keep autolinked local references
This commit is contained in:
mergify[bot] 2024-09-20 20:25:12 +00:00 committed by GitHub
commit 80994f459e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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