@velastack/cms 0.6.1 → 0.6.2

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.
@@ -168,6 +168,24 @@ export const resolveCmsPayload = async (args) => {
168
168
  redirectTo: null
169
169
  };
170
170
  };
171
+ /**
172
+ * A query parameter of the request, or null where the page cannot have one:
173
+ * while building, and on a prerendered page, where SvelteKit (3.0 in dev too,
174
+ * via `prerender_default`) replaces `url.search`/`url.searchParams` with a
175
+ * getter that throws `url_search_unavailable_prerender`. A prerendered page
176
+ * cannot vary by preview or version key, so null is the right answer, not an
177
+ * error that takes the whole page down in `vite dev`.
178
+ */
179
+ const searchParam = (event, key) => {
180
+ if (building)
181
+ return null;
182
+ try {
183
+ return event.url.searchParams.get(key);
184
+ }
185
+ catch {
186
+ return null;
187
+ }
188
+ };
171
189
  /**
172
190
  * Resolve the CMS payload for the current SvelteKit request.
173
191
  *
@@ -217,8 +235,8 @@ export const loadCms = (event, options) => {
217
235
  manifest: builtManifest,
218
236
  routeId: event.route.id,
219
237
  params: event.params,
220
- previewKey: building ? null : event.url.searchParams.get('preview'),
221
- versionKey: building ? null : event.url.searchParams.get('version'),
238
+ previewKey: searchParam(event, 'preview'),
239
+ versionKey: searchParam(event, 'version'),
222
240
  locale: options.locale,
223
241
  locales: options.locales,
224
242
  adapter: options.adapter,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velastack/cms",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "A scope-aware CMS for SvelteKit, for static or dynamic sites.",
5
5
  "keywords": [
6
6
  "svelte",