|
1 | 1 | <script lang="ts"> |
2 | | - import { afterNavigate, goto } from '$app/navigation' |
| 2 | + import { goto } from '$app/navigation' |
3 | 3 | import { page } from '$app/state' |
4 | 4 | import { CmdPalette } from '$lib' |
5 | 5 | import { repository } from '$root/package.json' |
6 | 6 | import { Footer } from '$site' |
7 | | - import { demos } from '$site/stores' |
8 | | - import { mount, type Snippet } from 'svelte' |
| 7 | + import { type Snippet } from 'svelte' |
9 | 8 | import Toc from 'svelte-toc' |
10 | 9 | import { CopyButton, GitHubCorner } from 'svelte-zoo' |
11 | 10 | import '../app.css' |
| 11 | + import { routes } from './(demos)' |
12 | 12 |
|
13 | 13 | interface Props { |
14 | 14 | children?: Snippet |
15 | 15 | } |
16 | 16 | let { children }: Props = $props() |
17 | 17 |
|
18 | | - afterNavigate(() => { |
19 | | - for (const node of document.querySelectorAll(`pre > code`)) { |
20 | | - // skip if <pre> already contains a button (presumably for copy) |
21 | | - const pre = node.parentElement |
22 | | - if (!pre || pre.querySelector(`button`)) continue |
23 | | -
|
24 | | - mount(CopyButton, { |
25 | | - target: pre, |
26 | | - props: { |
27 | | - content: node.textContent ?? ``, |
28 | | - style: `position: absolute; top: 1ex; right: 1ex;`, |
29 | | - }, |
30 | | - }) |
31 | | - } |
32 | | - }) |
33 | | -
|
34 | | - const routes = Object.keys(import.meta.glob(`./**/+page.{svx,svelte,md}`)).map( |
35 | | - (filename) => { |
36 | | - const parts = filename.split(`/`).filter((part) => !part.startsWith(`(`)) // remove hidden route segments |
37 | | - return { route: `/${parts.slice(1, -1).join(`/`)}`, filename } |
38 | | - }, |
39 | | - ) |
40 | | -
|
41 | | - if (routes.length < 3) { |
42 | | - console.error(`Too few demo routes found: ${routes.length}`) |
43 | | - } |
44 | | -
|
45 | | - $demos = routes |
46 | | - .filter(({ filename }) => filename.includes(`/(demos)/`)) |
47 | | - .map(({ route }) => route) |
48 | | -
|
49 | 18 | const actions = routes.map(({ route }) => ({ label: route, action: () => goto(route) })) |
50 | 19 | </script> |
51 | 20 |
|
52 | 21 | <CmdPalette {actions} placeholder="Go to..." /> |
53 | 22 |
|
54 | 23 | <GitHubCorner href={repository} /> |
55 | 24 |
|
| 25 | +<CopyButton global /> |
| 26 | + |
56 | 27 | {#if !page.error && page.url.pathname !== `/`} |
57 | 28 | <a href="." aria-label="Back to index page">« home</a> |
58 | 29 | {/if} |
|
64 | 35 | headingSelector="main > :where(h2, h3)" |
65 | 36 | breakpoint={1250} |
66 | 37 | --toc-mobile-bg="#1c0e3e" |
67 | | - --toc-font-size="9pt" |
68 | 38 | --toc-li-padding="3pt 1ex" |
69 | 39 | --toc-mobile-btn-color="white" |
70 | | - --toc-max-width="20em" |
71 | | - --toc-desktop-nav-margin="0 0 0 17em" |
| 40 | + --toc-desktop-nav-margin="0 0 0 14em" |
| 41 | + aside_style="max-width: 24em;" |
| 42 | + title_element_style="font-size: 16pt; padding: 0 0 0.5em 0.5em;" |
| 43 | + ol_style="font-size: 8pt" |
72 | 44 | /> |
73 | 45 | {/if} |
74 | 46 |
|
|
0 commit comments