create-shapio 0.5.2 → 0.5.3
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 +1 -1
- package/templates/astro/package.json +2 -2
- package/templates/astro/scripts/incrementalBuild.ts +10 -0
- package/templates/astro/src/lib/shapio.ts +8 -3
- package/templates/next/package.json +3 -3
- package/templates/next/src/lib/shapio.ts +8 -3
- package/templates/sveltekit/package.json +2 -2
- package/templates/sveltekit/src/lib/server/shapio.ts +8 -3
package/package.json
CHANGED
|
@@ -73,6 +73,13 @@ const slugAt = async (change: SnapshotChange, locale: string, snapshot: number):
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* The models whose entries have a route of their own, found by slug. Any other model (a redirect type a user
|
|
78
|
+
* adds, say) maps to no route here: it may have no `slug` field, and Astro's incremental build still decides
|
|
79
|
+
* page by page what to rebuild.
|
|
80
|
+
*/
|
|
81
|
+
const SLUG_ROUTED_MODELS = new Set(['page', 'article']);
|
|
82
|
+
|
|
76
83
|
/** Site routes (src/pages) an entry change touches. */
|
|
77
84
|
const routesOf = async (change: SnapshotChange, from: number, to: number): Promise<string[]> => {
|
|
78
85
|
const routes: string[] = [];
|
|
@@ -81,6 +88,9 @@ const routesOf = async (change: SnapshotChange, from: number, to: number): Promi
|
|
|
81
88
|
routes.push(`/${locale}/articles/`);
|
|
82
89
|
continue;
|
|
83
90
|
}
|
|
91
|
+
if (!SLUG_ROUTED_MODELS.has(change.modelKey)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
84
94
|
// An unpublished entry's route is where it was; the others are where they are now.
|
|
85
95
|
const slug = await slugAt(change, locale, kind === 'unpublished' ? from : to);
|
|
86
96
|
if (slug === null) {
|
|
@@ -64,17 +64,22 @@ export const pinnedSnapshot = async (): Promise<number | undefined> => {
|
|
|
64
64
|
return resolver();
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
/**
|
|
68
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Every published entry of a collection (by plural API ID) in one locale, page by page, at the pinned snapshot.
|
|
69
|
+
* The defaults (server-rendered HTML, SEO fields resolved) apply unless the query overrides them: a collection
|
|
70
|
+
* without SEO fields (a redirect type, say) is read with `{ seo: 'raw' }`, since Shapio refuses `seo=resolved`
|
|
71
|
+
* for a model that has none.
|
|
72
|
+
*/
|
|
73
|
+
export const listAll = async <T>(routeKey: string, query: DeliveryListQuery): Promise<T[]> => {
|
|
69
74
|
const snapshot = await pinnedSnapshot();
|
|
70
75
|
const entries: T[] = [];
|
|
71
76
|
for (let page = 1; ; page += 1) {
|
|
72
77
|
const result = await shapio().delivery.list<T>(routeKey, {
|
|
73
|
-
...query,
|
|
74
78
|
// The site renders the server's sanitized HTML, so it asks for that instead of the JSON document, and
|
|
75
79
|
// its SEO fields with the site's defaults filled in (`seo=resolved`).
|
|
76
80
|
richText: 'html',
|
|
77
81
|
seo: 'resolved',
|
|
82
|
+
...query,
|
|
78
83
|
snapshot,
|
|
79
84
|
page,
|
|
80
85
|
pageSize: PAGE_SIZE,
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@shapio/client": "^0.5.
|
|
22
|
-
"@shapio/local": "0.5.
|
|
23
|
-
"@shapio/visual": "^0.5.
|
|
21
|
+
"@shapio/client": "^0.5.3",
|
|
22
|
+
"@shapio/local": "0.5.3",
|
|
23
|
+
"@shapio/visual": "^0.5.3",
|
|
24
24
|
"next": "16.3.8",
|
|
25
25
|
"react": "19.3.0",
|
|
26
26
|
"react-dom": "19.3.0"
|
|
@@ -58,16 +58,21 @@ const snapshot = async (): Promise<number | undefined> =>
|
|
|
58
58
|
}))()
|
|
59
59
|
: liveSnapshot();
|
|
60
60
|
|
|
61
|
-
/**
|
|
62
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Every published entry of a collection in one locale, page by page, at the pinned snapshot.
|
|
63
|
+
* The defaults (server-rendered HTML, SEO fields resolved) apply unless the query overrides them: a collection
|
|
64
|
+
* without SEO fields (a redirect type, say) is read with `{ seo: 'raw' }`, since Shapio refuses `seo=resolved`
|
|
65
|
+
* for a model that has none.
|
|
66
|
+
*/
|
|
67
|
+
export const listAll = async <T>(routeKey: string, query: DeliveryListQuery): Promise<T[]> => {
|
|
63
68
|
const entries: T[] = [];
|
|
64
69
|
for (let page = 1; ; page += 1) {
|
|
65
70
|
const result = await shapio().delivery.list<T>(routeKey, {
|
|
66
|
-
...query,
|
|
67
71
|
// The site renders the server's sanitized HTML, so it asks for that instead of the JSON document, and
|
|
68
72
|
// its SEO fields with the site's defaults filled in.
|
|
69
73
|
richText: 'html',
|
|
70
74
|
seo: 'resolved',
|
|
75
|
+
...query,
|
|
71
76
|
snapshot: await snapshot(),
|
|
72
77
|
page,
|
|
73
78
|
pageSize: PAGE_SIZE,
|
|
@@ -57,16 +57,21 @@ const once = <T>(key: string, read: () => Promise<T>): Promise<T> => {
|
|
|
57
57
|
return cached();
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
/**
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Every published entry of a collection in one locale, page by page, at the pinned snapshot.
|
|
62
|
+
* The defaults (server-rendered HTML, SEO fields resolved) apply unless the query overrides them: a collection
|
|
63
|
+
* without SEO fields (a redirect type, say) is read with `{ seo: 'raw' }`, since Shapio refuses `seo=resolved`
|
|
64
|
+
* for a model that has none.
|
|
65
|
+
*/
|
|
66
|
+
export const listAll = async <T>(routeKey: string, query: DeliveryListQuery): Promise<T[]> => {
|
|
62
67
|
const entries: T[] = [];
|
|
63
68
|
for (let page = 1; ; page += 1) {
|
|
64
69
|
const result = await shapio().delivery.list<T>(routeKey, {
|
|
65
|
-
...query,
|
|
66
70
|
// The site renders the server's sanitized HTML, so it asks for that instead of the JSON document, and
|
|
67
71
|
// its SEO fields with the site's defaults filled in.
|
|
68
72
|
richText: 'html',
|
|
69
73
|
seo: 'resolved',
|
|
74
|
+
...query,
|
|
70
75
|
snapshot: await snapshot(),
|
|
71
76
|
page,
|
|
72
77
|
pageSize: PAGE_SIZE,
|