Fix changelog page rendering markdown links as raw text (#320)

The InlineCode component only handled backtick code spans but ignored
markdown links, causing PR/issue references to display as raw
[#N](url) text instead of clickable links. Rename to InlineMarkdown
and add link parsing to the split regex.
This commit is contained in:
Lawrence Chen 2026-02-22 16:24:59 -08:00 committed by GitHub
parent 146de6030e
commit 26d44e84da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,17 +75,24 @@ function parseChangelog(markdown: string): ChangelogVersion[] {
return versions;
}
function InlineCode({ text }: { text: string }) {
const parts = text.split(/(`[^`]+`)/g);
function InlineMarkdown({ text }: { text: string }) {
const parts = text.split(/(`[^`]+`|\[[^\]]+\]\([^)]+\))/g);
return (
<>
{parts.map((part, i) =>
part.startsWith("`") && part.endsWith("`") ? (
<code key={i}>{part.slice(1, -1)}</code>
) : (
<span key={i}>{part}</span>
)
)}
{parts.map((part, i) => {
if (part.startsWith("`") && part.endsWith("`")) {
return <code key={i}>{part.slice(1, -1)}</code>;
}
const linkMatch = part.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
if (linkMatch) {
return (
<a key={i} href={linkMatch[2]}>
{linkMatch[1]}
</a>
);
}
return <span key={i}>{part}</span>;
})}
</>
);
}
@ -115,7 +122,7 @@ export default function ChangelogPage() {
<ul>
{section.items.map((item, j) => (
<li key={j}>
<InlineCode text={item} />
<InlineMarkdown text={item} />
</li>
))}
</ul>