@pyreon/create-zero 0.15.0 → 0.18.0
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/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useHead } from "@pyreon/head"
|
|
2
2
|
import { useLoaderData } from "@pyreon/router"
|
|
3
3
|
import type { LoaderContext } from "@pyreon/zero"
|
|
4
|
+
import type { GetStaticPaths } from "@pyreon/zero/server"
|
|
4
5
|
import { Link } from "@pyreon/zero/link"
|
|
5
6
|
|
|
6
7
|
interface Post {
|
|
@@ -55,6 +56,19 @@ const POSTS: Record<string, Post> = {
|
|
|
55
56
|
},
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Enumerate the dynamic `:id` values for SSG prerendering. Required when
|
|
61
|
+
* the app is built with `mode: 'ssg'` (otherwise `pyreon doctor --check-ssg`
|
|
62
|
+
* warns and the SSG plugin silently skips this route). Harmless under
|
|
63
|
+
* `mode: 'ssr' | 'isr'` — the loader below still drives the per-request
|
|
64
|
+
* render in those modes.
|
|
65
|
+
*
|
|
66
|
+
* Replace this with your real enumeration (CMS fetch / DB query /
|
|
67
|
+
* filesystem walk) once you've wired up the data source.
|
|
68
|
+
*/
|
|
69
|
+
export const getStaticPaths: GetStaticPaths<{ id: string }> = () =>
|
|
70
|
+
Object.keys(POSTS).map((id) => ({ params: { id } }))
|
|
71
|
+
|
|
58
72
|
export async function loader(ctx: LoaderContext) {
|
|
59
73
|
await new Promise((r) => setTimeout(r, 50))
|
|
60
74
|
const post = POSTS[ctx.params.id]
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
+
import type { GetStaticPaths } from "@pyreon/zero/server"
|
|
1
2
|
import { useHead } from "@pyreon/head"
|
|
2
3
|
import { Link } from "@pyreon/zero/link"
|
|
3
4
|
import { useRoute } from "@pyreon/router"
|
|
4
5
|
import { postBySlug, postSlugs } from "../../lib/posts"
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Enumerate the dynamic `:slug` values at build time. The SSG plugin expands
|
|
9
|
+
* `/blog/:slug` × this list into one prerendered HTML file per post
|
|
10
|
+
* (`dist/blog/<slug>/index.html`). Without this export the dynamic route
|
|
11
|
+
* is silently skipped during SSG auto-detect — only the static `/blog`
|
|
12
|
+
* index would be prerendered, and `pyreon doctor --check-ssg` warns
|
|
13
|
+
* about it.
|
|
9
14
|
*/
|
|
10
|
-
export const
|
|
15
|
+
export const getStaticPaths: GetStaticPaths<{ slug: string }> = () =>
|
|
16
|
+
postSlugs().map((slug) => ({ params: { slug } }))
|
|
11
17
|
|
|
12
18
|
export default function PostPage() {
|
|
13
19
|
// useRoute() returns an accessor — call it to read the resolved route.
|
|
@@ -2,6 +2,7 @@ import { signal } from "@pyreon/reactivity"
|
|
|
2
2
|
import { onMount } from "@pyreon/core"
|
|
3
3
|
import { useHead } from "@pyreon/head"
|
|
4
4
|
import { useRoute } from "@pyreon/router"
|
|
5
|
+
import type { GetStaticPaths } from "@pyreon/zero/server"
|
|
5
6
|
import { Link } from "@pyreon/zero/link"
|
|
6
7
|
import {
|
|
7
8
|
DocDocument,
|
|
@@ -19,6 +20,22 @@ import { type Invoice, invoiceById, invoiceTotal } from "../../../lib/db"
|
|
|
19
20
|
|
|
20
21
|
export const meta = { title: "Invoice" }
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Enumerate the dynamic `:id` values for SSG prerendering. The dashboard
|
|
25
|
+
* scaffolds in `mode: 'ssr'` by default (invoices are tenant-scoped and
|
|
26
|
+
* fetched per-request), so this export is unused at runtime. It exists
|
|
27
|
+
* so that `pyreon doctor --check-ssg` doesn't warn AND so the route still
|
|
28
|
+
* works under `mode: 'ssg'` if you swap to a fully-static deploy with
|
|
29
|
+
* known invoice IDs.
|
|
30
|
+
*
|
|
31
|
+
* Replace the placeholder IDs with your real invoice enumeration (DB
|
|
32
|
+
* query / API fetch) when configuring SSG deploys.
|
|
33
|
+
*/
|
|
34
|
+
export const getStaticPaths: GetStaticPaths<{ id: string }> = () => [
|
|
35
|
+
{ params: { id: "demo-001" } },
|
|
36
|
+
{ params: { id: "demo-002" } },
|
|
37
|
+
]
|
|
38
|
+
|
|
22
39
|
/**
|
|
23
40
|
* The headline demo of `@pyreon/document-primitives`: this template renders
|
|
24
41
|
* directly in the browser preview AND exports to PDF/email/etc. without
|