Skip to content

Repair interlinks in the docs#72

Open
fetsorn wants to merge 1 commit into
comunica:masterfrom
fetsorn:master
Open

Repair interlinks in the docs#72
fetsorn wants to merge 1 commit into
comunica:masterfrom
fetsorn:master

Conversation

@fetsorn

@fetsorn fetsorn commented May 4, 2026

Copy link
Copy Markdown

Some links were broken because next.js doesn't rewrite markdown links in html anchors. I tried to add support for it in components but didn't like the code. So i just replaced broken links with public URLs.

for context, here's the solution i dismissed. it repaired the links, but even if cleaned up it could always touch some link it shouldn't and mangle source, so i think public URLs in markdown is better direction.

// components/Markdown.js
const Link = ({node, href, children, ...props}) => {
    if (href && href.includes('.md')) {
        href = href
            .replace(/\.md(#|$)/, '/$1')
            .replace(/(^|\/)\.\.\/(?!\.)/g, '$1../../')
            .replace(/(^|\/)[0-9]*_/g, '$1');
        if (!/^(\/|\.\.\/|https?:\/\/|#)/.test(href)) {
            href = '../' + href;
        }
    }
    return <a href={href} {...props}>{children}</a>;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant