|
1 | 1 | <script lang="ts"> |
2 | 2 | import { onDestroy } from 'svelte'; |
3 | 3 | import { base } from '$app/paths'; |
4 | | - import { goto } from '$app/navigation'; |
5 | | - import Icon from '$lib/components/common/Icon.svelte'; |
6 | 4 | import Tooltip from '$lib/components/common/Tooltip.svelte'; |
7 | 5 | import { packages, type PackageId } from '$lib/config/packages'; |
8 | 6 | import { groupByCategory, type NotebookMeta, type Category } from '$lib/notebook/manifest'; |
|
13 | 11 |
|
14 | 12 | let pkg = $derived(packages[data.packageId]); |
15 | 13 |
|
| 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 | +
|
16 | 18 | // Grouped notebooks from the version manifest |
17 | 19 | let groupedNotebooks = $derived.by(() => { |
18 | 20 | if (!data.versionManifest) return new Map<Category, NotebookMeta[]>(); |
|
40 | 42 | exampleGroupsStore.set([]); |
41 | 43 | }); |
42 | 44 |
|
43 | | - function navigateToExample(slug: string) { |
44 | | - goto(`${base}/${data.packageId}/${data.resolvedTag}/examples/${slug}`); |
45 | | - } |
46 | | -
|
47 | 45 | function getThumbnailUrl(thumbnail: string): string { |
48 | 46 | return `${base}/${data.packageId}/${data.resolvedTag}/figures/${thumbnail}`; |
49 | 47 | } |
|
67 | 65 |
|
68 | 66 | <div class="tile-grid cols-2"> |
69 | 67 | {#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"> |
77 | 69 | <div class="panel-header">{notebook.title}</div> |
78 | 70 | <div class="panel-body tile-body"> |
79 | 71 | <p class="tile-description">{notebook.description}</p> |
|
83 | 75 | </div> |
84 | 76 | {/if} |
85 | 77 | </div> |
86 | | - </div> |
| 78 | + </a> |
87 | 79 | {/each} |
88 | 80 | </div> |
89 | 81 | {/each} |
|
100 | 92 | height: var(--space-2xl); |
101 | 93 | } |
102 | 94 |
|
103 | | - /* Example tile - clickable */ |
| 95 | + /* Example tile - real <a> link, but should look like the surrounding tiles */ |
104 | 96 | .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; |
106 | 104 | } |
107 | 105 |
|
108 | 106 | /* Tile description text */ |
|
0 commit comments