Skip to content

Commit 9412126

Browse files
committed
sharing links are open
1 parent 1d64167 commit 9412126

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

apps/svelte.dev/src/lib/server/content.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export interface PackageCalculated {
238238

239239
export interface Category {
240240
title: string;
241+
hash: string;
241242
description?: string;
242243
packages: Package[];
243244
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const homepage: Category[] = [];
2626
for (const { packages, title, description } of PACKAGES_META.FEATURED) {
2727
homepage.push({
2828
title,
29+
hash: title.toLowerCase().replace(/ /g, '-'),
2930
description,
3031
packages: arrToPackages(packages)
3132
});

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import Category from './Category.svelte';
3+
import { page } from '$app/state';
34
45
const { data } = $props();
56
</script>
@@ -22,8 +23,8 @@
2223
</header>
2324

2425
<div>
25-
{#each data.homepage as { title, description, packages }}
26-
<Category {title} {description} {packages} />
26+
{#each data.homepage as category}
27+
<Category {...category} open={page.url.hash === `#${category.hash}`} />
2728
{/each}
2829
</div>
2930
</div>

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
<script lang="ts">
22
import type { Package } from '$lib/server/content';
33
import PackageCard from './PackageCard.svelte';
4+
import type { Category } from '$lib/server/content';
45
5-
interface Props {
6-
title: string;
7-
packages: Package[];
8-
description?: string;
9-
}
6+
type Props = {
7+
open: boolean;
8+
} & Category
109
11-
let { title, description, packages }: Props = $props();
12-
const slug = $derived(`${title.toLowerCase().replace(/ /g, '-')}`);
10+
let { title, description, packages, hash, open }: Props = $props();
1311
1412
const INITIAL_ITEMS = 3;
1513
</script>
1614

1715
<section class="category">
1816
<header>
19-
<h2 id={slug}>
17+
<h2 id={hash}>
2018
<span>{title}</span>
21-
<a href="#{slug}" class="permalink" aria-label="permalink">aa</a>
19+
<a href="#{hash}" class="permalink" aria-label="permalink">aa</a>
2220
</h2>
2321

2422
{#if description}
@@ -35,7 +33,7 @@
3533
</div>
3634

3735
{#if packages.length > INITIAL_ITEMS}
38-
<details>
36+
<details {open}>
3937
<summary>
4038
<span class="raised button" aria-label="Toggle">
4139
<span class="icon"></span>
@@ -154,7 +152,7 @@
154152
155153
/* permalink */
156154
[id] {
157-
scroll-margin-top: calc(var(--sk-nav-height)) !important;
155+
scroll-margin-top: calc(var(--sk-nav-height) + 2rem) !important;
158156
}
159157
160158
a.permalink {

0 commit comments

Comments
 (0)