Skip to content

Commit 06034bb

Browse files
committed
Render example tiles as real <a> links so prerender crawler finds each slug
1 parent 1f5f070 commit 06034bb

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<script lang="ts">
22
import { onDestroy } from 'svelte';
33
import { base } from '$app/paths';
4-
import { goto } from '$app/navigation';
5-
import Icon from '$lib/components/common/Icon.svelte';
64
import Tooltip from '$lib/components/common/Tooltip.svelte';
75
import { packages, type PackageId } from '$lib/config/packages';
86
import { groupByCategory, type NotebookMeta, type Category } from '$lib/notebook/manifest';
@@ -13,6 +11,10 @@
1311
1412
let pkg = $derived(packages[data.packageId]);
1513
14+
// Base path for example detail links — must be a real href so the
15+
// adapter-static crawler discovers each slug and prerenders it.
16+
let examplesBasePath = $derived(`${base}/${data.packageId}/${data.resolvedTag}/examples`);
17+
1618
// Grouped notebooks from the version manifest
1719
let groupedNotebooks = $derived.by(() => {
1820
if (!data.versionManifest) return new Map<Category, NotebookMeta[]>();
@@ -40,10 +42,6 @@
4042
exampleGroupsStore.set([]);
4143
});
4244
43-
function navigateToExample(slug: string) {
44-
goto(`${base}/${data.packageId}/${data.resolvedTag}/examples/${slug}`);
45-
}
46-
4745
function getThumbnailUrl(thumbnail: string): string {
4846
return `${base}/${data.packageId}/${data.resolvedTag}/figures/${thumbnail}`;
4947
}
@@ -67,13 +65,7 @@
6765

6866
<div class="tile-grid cols-2">
6967
{#each notebooks as notebook}
70-
<div
71-
class="tile example-tile elevated"
72-
onclick={() => navigateToExample(notebook.slug)}
73-
onkeydown={(e) => e.key === 'Enter' && navigateToExample(notebook.slug)}
74-
role="button"
75-
tabindex="0"
76-
>
68+
<a href="{examplesBasePath}/{notebook.slug}" class="tile example-tile elevated">
7769
<div class="panel-header">{notebook.title}</div>
7870
<div class="panel-body tile-body">
7971
<p class="tile-description">{notebook.description}</p>
@@ -83,7 +75,7 @@
8375
</div>
8476
{/if}
8577
</div>
86-
</div>
78+
</a>
8779
{/each}
8880
</div>
8981
{/each}
@@ -100,9 +92,15 @@
10092
height: var(--space-2xl);
10193
}
10294
103-
/* Example tile - clickable */
95+
/* Example tile - real <a> link, but should look like the surrounding tiles */
10496
.example-tile {
105-
cursor: pointer;
97+
display: block;
98+
color: inherit;
99+
text-decoration: none;
100+
}
101+
102+
.example-tile:hover {
103+
text-decoration: none;
106104
}
107105
108106
/* Tile description text */

0 commit comments

Comments
 (0)