Skip to content

Commit 6313480

Browse files
fix: multiple fixes
- fix <svelte:*> elements being interpreted as links (even GH itself does this wrong lol - fix too much spacing on the left of the Open Details arrow - not a fix but use the display font for the details page sections - fix the deprecation package details tooltip wrapping its text too early - fix links not being GitHub-formatted on releases bodies (noticeable in `extensions`)
1 parent f65173a commit 6313480

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

src/lib/components/MarkdownRenderer.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,21 @@
2525
} & MdSnippets;
2626
2727
let {
28-
markdown: md,
28+
markdown,
2929
inline = false,
3030
parseRawHtml = false,
3131
additionalPlugins = [],
3232
class: className = undefined,
3333
...snippets
3434
}: Props = $props();
35+
36+
// Markdown renders <thing:*> as a link (yeah I didn't know either).
37+
// We don't want that to break Svelte's special elements, so we escape this.
38+
//
39+
// Refs:
40+
// - https://www.markdownguide.org/basic-syntax/#urls-and-email-addresses
41+
// - https://svelte.dev/docs/svelte/svelte-boundary (and others)
42+
let md = $derived(markdown.replace(/<(svelte:\S+)>/g, "&lt;$1&gt;"));
3543
</script>
3644

3745
<svelte:element

src/lib/components/renderers/ListElementRenderer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
class="ml-2 !inline-flex h-auto !p-0 transition-[translate,_opacity] duration-300 group-hover:translate-x-0 group-hover:opacity-100 md:ml-4 md:-translate-x-2 md:opacity-0 lg:mr-8"
6060
>
6161
Open details
62-
<ArrowRight class="ml-2 size-4" />
62+
<ArrowRight class="size-4" />
6363
</Button>
6464
{/if}
6565
</li>

src/routes/[pid=pid]/[org]/[repo]/[id=number]/PageRenderer.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
</a>
279279
</h2>
280280
{#if linkedEntities.length > 0}
281-
<h3 class="text-2xl font-semibold tracking-tight">
281+
<h3 class="font-display text-2xl font-semibold tracking-tight">
282282
{metadata.type === "pull" ? "Closing issue" : "Development PR"}{linkedEntities.length > 1
283283
? "s"
284284
: ""}
@@ -345,7 +345,7 @@
345345
</Accordion.Root>
346346
{/if}
347347
<div class="flex items-center">
348-
<h3 class="text-2xl font-semibold tracking-tight">
348+
<h3 class="font-display text-2xl font-semibold tracking-tight">
349349
{metadata.type === "pull" ? "Pull request" : metadata.type === "issue" ? "Issue" : "Discussion"}
350350
</h3>
351351
{#if info.locked}

src/routes/package/[...package]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
<MarkdownRenderer
231231
markdown={data.currentPackage.pkg.deprecated}
232232
inline
233-
class="text-sm text-muted-foreground"
233+
class="max-w-full text-sm text-muted-foreground"
234234
>
235235
{#snippet a({ style, children, class: className, title, href, hidden, type })}
236236
<a {style} class={className} {title} {href} {hidden} {type} target="_blank">

src/routes/package/[...package]/ReleaseCard.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import { page } from "$app/state";
44
import { ArrowUpRight } from "@lucide/svelte";
55
import { confetti } from "@neoconfetti/svelte";
6+
import remarkGemoji from "remark-gemoji";
7+
import remarkGithub from "remark-github";
68
import semver from "semver";
79
import type { GitHubRelease } from "$lib/server/github-cache";
810
import * as Accordion from "$lib/components/ui/accordion";
@@ -312,7 +314,11 @@
312314
<div class="relative mt-4 flex flex-col gap-2">
313315
<MarkdownRenderer
314316
markdown={releaseBody}
315-
additionalPlugins={[{ renderer: { li: ListElementRenderer } }]}
317+
additionalPlugins={[
318+
{ remarkPlugin: [remarkGithub, { repository: `${repo.owner}/${repo.name}` }] },
319+
{ remarkPlugin: remarkGemoji },
320+
{ renderer: { li: ListElementRenderer } }
321+
]}
316322
class="prose-sm max-w-full prose-p:my-0"
317323
/>
318324
<div class="flex items-end-safe justify-between gap-8">

0 commit comments

Comments
 (0)