Skip to content

Commit 1555565

Browse files
committed
always link
1 parent 1156513 commit 1555565

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

apps/svelte.dev/src/routes/packages/PackageCard.svelte

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@
1717
hour: 'numeric',
1818
minute: 'numeric'
1919
});
20+
21+
const href = $derived(pkg.homepage || pkg.repo_url || `https://npmjs.org/package/${pkg.name}`);
2022
</script>
2123

2224
<article>
23-
{#snippet contents()}
25+
<a
26+
class="contents"
27+
{href}
28+
target={href.startsWith('/') ? null : '_blank'}
29+
rel="noreferrer"
30+
aria-label="View project homepage"
31+
onclick={(e) => e.stopPropagation()}
32+
>
2433
<header>
2534
<h3>
2635
{#if pkg.official}
@@ -58,24 +67,7 @@
5867

5968
<span style="flex: 1 1 auto"></span>
6069
</p>
61-
{/snippet}
62-
63-
{#if pkg.homepage}
64-
<a
65-
class="contents"
66-
href={pkg.homepage}
67-
target={pkg.homepage.startsWith('/') ? null : '_blank'}
68-
rel="noreferrer"
69-
aria-label="View project homepage"
70-
onclick={(e) => e.stopPropagation()}
71-
>
72-
{@render contents()}
73-
</a>
74-
{:else}
75-
<div class="contents">
76-
{@render contents()}
77-
</div>
78-
{/if}
70+
</a>
7971

8072
<!-- this is a sibling element so that we don't have links inside links -->
8173
<div class="links">

0 commit comments

Comments
 (0)