fix: github links (#840)

This commit is contained in:
Jason Rasmussen
2026-09-28 10:55:32 -04:00
committed by GitHub
parent a70297486c
commit 009b77ad78
4 changed files with 20 additions and 4 deletions
@@ -221,9 +221,14 @@ export const markedSvelte = (): MarkedExtension => ({
return `<Markdown.LineBreak />\n`;
},
link({ href, title, tokens }) {
link({ href, title, text: raw, tokens }) {
const attributes = createAttributes({ href, title });
if (raw === href) {
return `<Markdown.Link${attributes} />`;
}
const text = this.parser.parseInline(tokens);
return `<Markdown.Link${createAttributes({ href, title })}>${text}</Markdown.Link>`;
return `<Markdown.Link${attributes}>${text}</Markdown.Link>`;
},
codespan({ text }) {
@@ -191,12 +191,22 @@ exports[`markup > should render 'link.md' correctly 1`] = `
}
`;
exports[`markup > should render 'link-github.md' correctly 1`] = `
{
"code": "<script>
import { Markdown } from '@immich/ui';
</script>
<Markdown.Paragraph>This is a <Markdown.Link href="https://github.com/immich-app/immich/discussions/31232">custom GitHub link</Markdown.Link> and a bare one <Markdown.Link href="https://github.com/immich-app/immich/discussions/31232" /></Markdown.Paragraph>
",
}
`;
exports[`markup > should render 'link-shothand.md' correctly 1`] = `
{
"code": "<script>
import { Markdown } from '@immich/ui';
</script>
<Markdown.Paragraph>This is a shorthand link: <Markdown.Link href="https://immich.app/">https://immich.app/</Markdown.Link></Markdown.Paragraph>
<Markdown.Paragraph>This is a shorthand link: <Markdown.Link href="https://immich.app/" /></Markdown.Paragraph>
",
}
`;
@@ -0,0 +1 @@
This is a [custom GitHub link](https://github.com/immich-app/immich/discussions/31232) and a bare one <https://github.com/immich-app/immich/discussions/31232>
@@ -12,7 +12,7 @@
const { href, title, children }: Props = $props();
const github = $derived(parseGithubLink(href));
const github = $derived(children ? undefined : parseGithubLink(href));
</script>
{#if github}