toiljs 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +315 -1
- package/assets/logo.svg +37 -0
- package/build/cli/.tsbuildinfo +1 -1
- package/build/cli/configure.js +10 -4
- package/build/cli/create.js +60 -32
- package/build/cli/diagnostics.d.ts +55 -0
- package/build/cli/diagnostics.js +333 -0
- package/build/cli/doctor.d.ts +6 -0
- package/build/cli/doctor.js +249 -0
- package/build/cli/index.js +26 -0
- package/build/cli/proc.d.ts +5 -0
- package/build/cli/proc.js +20 -0
- package/build/cli/ui.d.ts +1 -0
- package/build/cli/ui.js +1 -0
- package/build/cli/update.d.ts +7 -0
- package/build/cli/update.js +117 -0
- package/build/cli/updates.d.ts +10 -0
- package/build/cli/updates.js +45 -0
- package/build/client/.tsbuildinfo +1 -1
- package/build/client/dev/error-overlay.js +1 -1
- package/build/client/head/metadata.js +3 -1
- package/build/client/index.d.ts +5 -1
- package/build/client/index.js +2 -0
- package/build/client/navigation/navigation.js +1 -1
- package/build/client/routing/Router.js +2 -2
- package/build/client/search/search.d.ts +26 -0
- package/build/client/search/search.js +101 -0
- package/build/client/search/use-page-search.d.ts +8 -0
- package/build/client/search/use-page-search.js +21 -0
- package/build/compiler/.tsbuildinfo +1 -1
- package/build/compiler/generate.js +35 -26
- package/build/compiler/index.d.ts +2 -0
- package/build/compiler/index.js +1 -0
- package/build/compiler/pages.d.ts +8 -0
- package/build/compiler/pages.js +37 -0
- package/build/compiler/plugin.js +3 -1
- package/build/compiler/prerender.d.ts +1 -0
- package/build/compiler/prerender.js +11 -5
- package/build/compiler/seo.js +10 -3
- package/build/compiler/vite.js +7 -0
- package/build/io/.tsbuildinfo +1 -1
- package/examples/basic/client/components/Header.tsx +43 -38
- package/examples/basic/client/components/HoneycombBackground.tsx +223 -230
- package/examples/basic/client/layout.tsx +4 -1
- package/examples/basic/client/public/index.html +18 -16
- package/examples/basic/client/routes/(legal)/privacy.tsx +18 -0
- package/examples/basic/client/routes/(legal)/terms.tsx +15 -0
- package/examples/basic/client/routes/about.tsx +21 -19
- package/examples/basic/client/routes/blog/[id].tsx +26 -12
- package/examples/basic/client/routes/features/actions.tsx +67 -0
- package/examples/basic/client/routes/features/error/error.tsx +16 -0
- package/examples/basic/client/routes/features/error/index.tsx +27 -0
- package/examples/basic/client/routes/features/head.tsx +38 -0
- package/examples/basic/client/routes/features/index.tsx +83 -0
- package/examples/basic/client/routes/features/realtime.tsx +34 -0
- package/examples/basic/client/routes/features/script.tsx +31 -0
- package/examples/basic/client/routes/features/seo.tsx +39 -0
- package/examples/basic/client/routes/features/template/b.tsx +14 -0
- package/examples/basic/client/routes/features/template/index.tsx +20 -0
- package/examples/basic/client/routes/features/template/template.tsx +16 -0
- package/examples/basic/client/routes/files/[[...slug]].tsx +21 -0
- package/examples/basic/client/routes/gallery/@modal/(.)photo/[id].tsx +23 -0
- package/examples/basic/client/routes/gallery/index.tsx +42 -0
- package/examples/basic/client/routes/gallery/layout.tsx +13 -0
- package/examples/basic/client/routes/gallery/photo/[id].tsx +18 -0
- package/examples/basic/client/routes/get-started.tsx +157 -84
- package/examples/basic/client/routes/index.tsx +137 -87
- package/examples/basic/client/routes/loader-demo/index.tsx +59 -50
- package/examples/basic/client/routes/search.tsx +61 -0
- package/examples/basic/client/routes/test.tsx +7 -8
- package/examples/basic/client/styles/main.css +624 -552
- package/examples/basic/client/toil.tsx +2 -4
- package/package.json +3 -2
- package/presets/eslint.js +10 -3
- package/src/cli/configure.ts +363 -353
- package/src/cli/create.ts +563 -530
- package/src/cli/diagnostics.ts +421 -0
- package/src/cli/doctor.ts +318 -0
- package/src/cli/features.ts +166 -160
- package/src/cli/index.ts +242 -211
- package/src/cli/proc.ts +30 -0
- package/src/cli/ui.ts +111 -103
- package/src/cli/update.ts +150 -0
- package/src/cli/updates.ts +69 -0
- package/src/client/components/Image.tsx +91 -89
- package/src/client/dev/error-overlay.tsx +193 -197
- package/src/client/head/metadata.ts +94 -92
- package/src/client/index.ts +79 -64
- package/src/client/navigation/Link.tsx +94 -100
- package/src/client/navigation/navigation.ts +215 -218
- package/src/client/routing/Router.tsx +210 -193
- package/src/client/routing/hooks.ts +110 -114
- package/src/client/routing/lazy.ts +77 -81
- package/src/client/search/search.ts +189 -0
- package/src/client/search/use-page-search.ts +73 -0
- package/src/compiler/config.ts +173 -171
- package/src/compiler/fonts.ts +89 -87
- package/src/compiler/generate.ts +378 -364
- package/src/compiler/image-report.ts +88 -85
- package/src/compiler/index.ts +2 -0
- package/src/compiler/pages.ts +70 -0
- package/src/compiler/plugin.ts +51 -47
- package/src/compiler/prerender.ts +152 -130
- package/src/compiler/routes.ts +132 -131
- package/src/compiler/seo.ts +381 -356
- package/src/compiler/vite.ts +155 -130
- package/src/io/FastSet.ts +99 -96
- package/test/configure.test.ts +94 -90
- package/test/doctor.test.ts +140 -0
- package/test/dom/Image.test.tsx +73 -46
- package/test/dom/Script.test.tsx +48 -45
- package/test/dom/action.test.tsx +146 -129
- package/test/dom/error-overlay.test.tsx +44 -44
- package/test/dom/loader.test.tsx +2 -2
- package/test/dom/revalidate.test.tsx +1 -1
- package/test/dom/route-head.test.tsx +35 -2
- package/test/dom/slot.test.tsx +131 -109
- package/test/dom/view-transitions.test.tsx +53 -51
- package/test/features.test.ts +149 -142
- package/test/fonts.test.ts +28 -26
- package/test/head.test.ts +45 -35
- package/test/metadata.test.ts +42 -41
- package/test/pages.test.ts +105 -0
- package/test/prerender.test.ts +54 -46
- package/test/search.test.ts +114 -0
- package/test/seo.test.ts +164 -142
- package/test/slot-layouts.test.ts +69 -0
- package/test/update.test.ts +44 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export const metadata: Toil.Metadata = {
|
|
4
|
+
title: 'Search',
|
|
5
|
+
description: 'Search every page by its metadata and jump straight to it.',
|
|
6
|
+
keywords: ['search', 'find', 'pages', 'metadata']
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
// A tiny site-wide search box. `usePageSearch` queries the compiler-built index of every page's
|
|
10
|
+
// metadata (title/description/keywords/OpenGraph + static `searchHints` on dynamic routes), returns
|
|
11
|
+
// ranked matches with their route `path`, and `goTo` navigates to whichever one you pick.
|
|
12
|
+
export default function Search() {
|
|
13
|
+
const [query, setQuery] = useState('');
|
|
14
|
+
const { results, pages, goTo } = Toil.usePageSearch(query, { includeDynamic: true });
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<main>
|
|
18
|
+
<h1>Search</h1>
|
|
19
|
+
<p>
|
|
20
|
+
Type to search across the metadata of all {pages.length} pages — title, description, keywords, and
|
|
21
|
+
OpenGraph. Indexed at build by <code>client/routes/*</code>.
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<input
|
|
25
|
+
type="search"
|
|
26
|
+
value={query}
|
|
27
|
+
onChange={(e) => {
|
|
28
|
+
setQuery(e.target.value);
|
|
29
|
+
}}
|
|
30
|
+
placeholder="Search pages… (try “blog”, “features”, “started”)"
|
|
31
|
+
aria-label="Search pages"
|
|
32
|
+
autoFocus
|
|
33
|
+
style={{ width: '100%', padding: '0.6rem 0.8rem', fontSize: '1rem' }}
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
{query.trim() !== '' && (
|
|
37
|
+
<ul style={{ listStyle: 'none', padding: 0, marginTop: '1rem' }}>
|
|
38
|
+
{results.length === 0 && <li>No pages match “{query}”.</li>}
|
|
39
|
+
{results.map((r) => (
|
|
40
|
+
<li key={r.page.path} style={{ marginBottom: '0.75rem' }}>
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
onClick={() => {
|
|
44
|
+
goTo(r);
|
|
45
|
+
}}
|
|
46
|
+
disabled={r.page.dynamic}
|
|
47
|
+
title={r.page.dynamic ? 'Dynamic route — needs params to open' : undefined}
|
|
48
|
+
style={{ textAlign: 'left', cursor: r.page.dynamic ? 'default' : 'pointer' }}>
|
|
49
|
+
<strong>{r.page.metadata.title ?? r.page.path}</strong> <code>{r.page.path}</code>
|
|
50
|
+
{r.page.metadata.description !== undefined && <div>{r.page.metadata.description}</div>}
|
|
51
|
+
<small>
|
|
52
|
+
score {r.score.toFixed(1)} · matched {r.matches.join(', ')}
|
|
53
|
+
</small>
|
|
54
|
+
</button>
|
|
55
|
+
</li>
|
|
56
|
+
))}
|
|
57
|
+
</ul>
|
|
58
|
+
)}
|
|
59
|
+
</main>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export default function TestPage() {
|
|
2
|
-
return (
|
|
3
|
-
<div className="test-page">
|
|
4
|
-
<img src="/images/test_image.webp" alt="Test" className="test-page-image" />
|
|
5
|
-
</div>
|
|
6
|
-
);
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
export default function TestPage() {
|
|
2
|
+
return (
|
|
3
|
+
<div className="test-page">
|
|
4
|
+
<img src="/images/test_image.webp" alt="Test" className="test-page-image" />
|
|
5
|
+
</div>
|
|
6
|
+
);
|
|
7
|
+
}
|