Skip to content

Commit 00868e5

Browse files
committed
better display of add-ons
1 parent a97e894 commit 00868e5

File tree

5 files changed

+30
-24
lines changed

5 files changed

+30
-24
lines changed

apps/svelte.dev/src/lib/packages-meta.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ const SV_ADD_CMD: Record<string, { alias: string; options?: string }> = {
3636
'@sveltejs/adapter-netlify': { alias: 'sveltekit-adapter', options: 'adapter:netlify' }
3737
};
3838

39-
const FEATURED: { title: string; alternative?: string; packages: string[]; weights?: Record<string, number> }[] = [
39+
const FEATURED: {
40+
title: string;
41+
alternative?: string;
42+
packages: string[];
43+
weights?: Record<string, number>;
44+
}[] = [
4045
{
4146
title: 'Component libraries',
4247
packages: [

apps/svelte.dev/src/lib/server/generated/registry/lucia.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lucia",
3-
"description": "Simple and flexible authentication library.",
3+
"description": "A guide for implementing authentication in JavaScript with examples for SvelteKit.",
44
"repo_url": "https://github.com/pilcrowOnPaper/lucia",
55
"authors": ["pilcrowonpaper"],
66
"homepage": "https://github.com/pilcrowOnPaper/lucia#readme",

apps/svelte.dev/src/routes/packages/+page.server.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ const arrToPackages = (arr: string[]) => {
2121
};
2222

2323
// Netflix style page. Send pre-done cards with categories
24-
const homepage: { title: string; href?: string; alternative?: string; packages: Package[] }[] = [
24+
const addons: { title: string; href?: string; alternative?: string; packages: Package[] }[] = [
2525
{
2626
title: 'Svelte CLI add-ons',
2727
href: '/docs/cli',
28-
packages: arrToPackages(PACKAGES_META.SV_ADD.packages)
28+
packages: arrToPackages(PACKAGES_META.SV_ADD.packages).map((pkg) => {
29+
pkg.name = pkg.svCmdAlias ?? pkg.name;
30+
pkg.homepage = `/docs/cli/${pkg.svCmdAlias}`;
31+
delete pkg.repo_url;
32+
return pkg;
33+
})
2934
}
3035
];
3136

37+
const homepage: { title: string; href?: string; alternative?: string; packages: Package[] }[] = [];
38+
3239
for (const { packages, title, alternative } of PACKAGES_META.FEATURED) {
3340
homepage.push({
3441
title,
@@ -40,6 +47,7 @@ for (const { packages, title, alternative } of PACKAGES_META.FEATURED) {
4047
export async function load() {
4148
return {
4249
packages: registry,
50+
addons,
4351
homepage
4452
};
4553
}

apps/svelte.dev/src/routes/packages/+page.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222

2323
<div class="page content">
2424
<div in:fly={{ y: 20 }}>
25+
{#each data.addons as { title, alternative, href, packages }}
26+
<Category {title} {alternative} {href} {packages} />
27+
{/each}
2528
{#each data.homepage as { title, alternative, href, packages }}
2629
<Category {title} {alternative} {href} {packages} />
2730
{/each}

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

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,6 @@
4545

4646
<p class="description">{pkg.description}</p>
4747

48-
{#if pkg.svCmdAlias}
49-
<span class="sv-cmd">
50-
npx sv add {pkg.svCmdAlias}{pkg.svCmdOptions ? `=${pkg.svCmdOptions}` : ''}
51-
<a
52-
href={`/docs/cli/${pkg.svCmdAlias}`}
53-
target="_blank"
54-
rel="noreferrer"
55-
aria-label="View Svelte CLI docs"
56-
data-icon="external-link"
57-
></a>
58-
</span>
59-
{/if}
6048
<p class="stats">
6149
{#if pkg.downloads}
6250
<span title="{pkg.downloads} downloads">
@@ -75,14 +63,16 @@
7563
<span style="flex: 1 1 auto"></span>
7664

7765
<span style="display: flex; gap: 0.75rem">
78-
<a
79-
href="https://npmjs.org/package/{pkg.name}"
80-
target="_blank"
81-
rel="noreferrer"
82-
data-icon="npm"
83-
aria-label="View on npm"
84-
onclick={(e) => e.stopPropagation()}
85-
></a>
66+
{#if !pkg.svCmdAlias}
67+
<a
68+
href="https://npmjs.org/package/{pkg.name}"
69+
target="_blank"
70+
rel="noreferrer"
71+
data-icon="npm"
72+
aria-label="View on npm"
73+
onclick={(e) => e.stopPropagation()}
74+
></a>
75+
{/if}
8676

8777
{#if pkg.repo_url}
8878
<a

0 commit comments

Comments
 (0)