@bagelink/blox 1.15.661 → 1.15.663

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.
@@ -12,6 +12,7 @@
12
12
  */
13
13
  export declare function useLocaleNav(): {
14
14
  switchLocale: (targetLocale: string) => void;
15
+ alternatePath: (targetLocale: string) => string;
15
16
  toPath: (slug: string) => string;
16
17
  localePath: (targetLocale: string, slug?: string) => string;
17
18
  detect: (path: string) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleNav.d.ts","sourceRoot":"","sources":["../../src/composables/useLocaleNav.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY;iCAYS,MAAM;mBAiBpB,MAAM,KAAG,MAAM;+BAOH,MAAM,oBAAe,MAAM;mBAYvC,MAAM,KAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;;;EAa/D"}
1
+ {"version":3,"file":"useLocaleNav.d.ts","sourceRoot":"","sources":["../../src/composables/useLocaleNav.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY;iCAYS,MAAM;kCAeL,MAAM,KAAG,MAAM;mBAI9B,MAAM,KAAG,MAAM;+BAOH,MAAM,oBAAe,MAAM;mBAYvC,MAAM,KAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;;;EAa/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"createBloxApp.d.ts","sourceRoot":"","sources":["../src/createBloxApp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,KAAK,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,KAAK,EAAE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;;GAiCG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAiK1E"}
package/dist/index.cjs CHANGED
@@ -138,9 +138,11 @@ function useLocaleNav() {
138
138
  });
139
139
  function switchLocale(targetLocale) {
140
140
  if (!strategy) return;
141
- const alts = currentAlternates.value;
142
- const alternateSlug = alts[targetLocale] ?? "/";
143
- strategy.switchTo(targetLocale, alternateSlug, router);
141
+ strategy.switchTo(targetLocale, alternatePath(targetLocale), router);
142
+ }
143
+ function alternatePath(targetLocale) {
144
+ var _a;
145
+ return ((_a = currentAlternates.value) == null ? void 0 : _a[targetLocale]) ?? "/";
144
146
  }
145
147
  function toPath(slug) {
146
148
  const normalized = appRuntime.normalizeLink(slug) ?? slug;
@@ -164,7 +166,7 @@ function useLocaleNav() {
164
166
  }
165
167
  return { locale: def, slug: path || "/" };
166
168
  }
167
- return { switchLocale, toPath, localePath, detect, availableLocales, locale };
169
+ return { switchLocale, alternatePath, toPath, localePath, detect, availableLocales, locale };
168
170
  }
169
171
  function usePageContext(key = "$page") {
170
172
  const contexts = vue.inject("contexts");
@@ -229,6 +231,12 @@ function safeRoute() {
229
231
  return null;
230
232
  }
231
233
  }
234
+ const NOT_FOUND_SLUG = "/404";
235
+ function isMissingPageDocument({ hydratedSlug, requestedSlug }) {
236
+ if (!hydratedSlug) return false;
237
+ if (hydratedSlug !== NOT_FOUND_SLUG) return false;
238
+ return requestedSlug !== NOT_FOUND_SLUG;
239
+ }
232
240
  const DEFAULT_PLAUSIBLE_HOST = "https://analytics.bagel.to";
233
241
  function injectPlausible(config) {
234
242
  var _a, _b;
@@ -255,7 +263,7 @@ function injectPlausible(config) {
255
263
  document.head.appendChild(el);
256
264
  }
257
265
  function createBloxApp(options) {
258
- var _a;
266
+ var _a, _b, _c;
259
267
  const {
260
268
  rootComponent,
261
269
  router,
@@ -337,6 +345,17 @@ function createBloxApp(options) {
337
345
  const initialPath = typeof window !== "undefined" && ((_a = window.location) == null ? void 0 : _a.pathname) ? window.location.pathname : router.currentRoute.value.path;
338
346
  appRuntime.setActiveLocale(localeOf(initialPath), localeState);
339
347
  appRuntime.setActiveLocale(localeOf(initialPath), localeState);
348
+ if (hasSsgState && strategy && typeof window !== "undefined") {
349
+ const hostname = window.location.hostname;
350
+ const hydratedPath = (_c = (_b = ssg_client.readBloxHydration()) == null ? void 0 : _b.route) == null ? void 0 : _c.path;
351
+ if (isMissingPageDocument({
352
+ hydratedSlug: hydratedPath ? strategy.detect(hostname, hydratedPath).slug : "",
353
+ requestedSlug: strategy.detect(hostname, initialPath).slug
354
+ })) {
355
+ window.location.replace(strategy.toPath("/", localeOf(initialPath)));
356
+ return { app, router, blox };
357
+ }
358
+ }
340
359
  router.isReady().then(() => {
341
360
  appRuntime.installSmartLinks(router);
342
361
  if (navigation === "document") installDocumentNavigation(router);
package/dist/index.mjs CHANGED
@@ -138,9 +138,11 @@ function useLocaleNav() {
138
138
  });
139
139
  function switchLocale(targetLocale) {
140
140
  if (!strategy) return;
141
- const alts = currentAlternates.value;
142
- const alternateSlug = alts[targetLocale] ?? "/";
143
- strategy.switchTo(targetLocale, alternateSlug, router);
141
+ strategy.switchTo(targetLocale, alternatePath(targetLocale), router);
142
+ }
143
+ function alternatePath(targetLocale) {
144
+ var _a;
145
+ return ((_a = currentAlternates.value) == null ? void 0 : _a[targetLocale]) ?? "/";
144
146
  }
145
147
  function toPath(slug) {
146
148
  const normalized = normalizeLink(slug) ?? slug;
@@ -164,7 +166,7 @@ function useLocaleNav() {
164
166
  }
165
167
  return { locale: def, slug: path || "/" };
166
168
  }
167
- return { switchLocale, toPath, localePath, detect, availableLocales, locale };
169
+ return { switchLocale, alternatePath, toPath, localePath, detect, availableLocales, locale };
168
170
  }
169
171
  function usePageContext(key = "$page") {
170
172
  const contexts = inject("contexts");
@@ -229,6 +231,12 @@ function safeRoute() {
229
231
  return null;
230
232
  }
231
233
  }
234
+ const NOT_FOUND_SLUG = "/404";
235
+ function isMissingPageDocument({ hydratedSlug, requestedSlug }) {
236
+ if (!hydratedSlug) return false;
237
+ if (hydratedSlug !== NOT_FOUND_SLUG) return false;
238
+ return requestedSlug !== NOT_FOUND_SLUG;
239
+ }
232
240
  const DEFAULT_PLAUSIBLE_HOST = "https://analytics.bagel.to";
233
241
  function injectPlausible(config) {
234
242
  var _a, _b;
@@ -255,7 +263,7 @@ function injectPlausible(config) {
255
263
  document.head.appendChild(el);
256
264
  }
257
265
  function createBloxApp(options) {
258
- var _a;
266
+ var _a, _b, _c;
259
267
  const {
260
268
  rootComponent,
261
269
  router,
@@ -337,6 +345,17 @@ function createBloxApp(options) {
337
345
  const initialPath = typeof window !== "undefined" && ((_a = window.location) == null ? void 0 : _a.pathname) ? window.location.pathname : router.currentRoute.value.path;
338
346
  setActiveLocale(localeOf(initialPath), localeState);
339
347
  setActiveLocale(localeOf(initialPath), localeState);
348
+ if (hasSsgState && strategy && typeof window !== "undefined") {
349
+ const hostname = window.location.hostname;
350
+ const hydratedPath = (_c = (_b = readBloxHydration()) == null ? void 0 : _b.route) == null ? void 0 : _c.path;
351
+ if (isMissingPageDocument({
352
+ hydratedSlug: hydratedPath ? strategy.detect(hostname, hydratedPath).slug : "",
353
+ requestedSlug: strategy.detect(hostname, initialPath).slug
354
+ })) {
355
+ window.location.replace(strategy.toPath("/", localeOf(initialPath)));
356
+ return { app, router, blox };
357
+ }
358
+ }
340
359
  router.isReady().then(() => {
341
360
  installSmartLinks(router);
342
361
  if (navigation === "document") installDocumentNavigation(router);
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A host (Netlify) serves the site's not-found document for any path that has no
3
+ * prerendered page, with an HTTP 404 status. JavaScript cannot read that status,
4
+ * but the document's embedded hydration payload describes the not-found page, so
5
+ * comparing it with the current URL is the only client-visible signal that the
6
+ * requested page does not exist.
7
+ *
8
+ * Used at boot: if we are NOT on the not-found page itself, the URL is missing
9
+ * and the visitor should go to the homepage of the requested language. Acting
10
+ * before mount also prevents hydrating a 404 document against a different view
11
+ * (which produces hydration mismatches and a broken nav/page).
12
+ */
13
+ /** Route slug of the site's not-found page. */
14
+ export declare const NOT_FOUND_SLUG = "/404";
15
+ export interface NotFoundDetection {
16
+ /** Hydrated page's route path (from the SSG payload), if any. */
17
+ hydratedPath?: string | null;
18
+ /** Locale-stripped slug of the URL actually requested. */
19
+ requestedSlug: string;
20
+ /** Locale-stripped slug of the hydrated page. */
21
+ hydratedSlug: string;
22
+ }
23
+ /**
24
+ * True when the loaded document is the not-found page but the requested URL is
25
+ * something else — i.e. the URL does not exist and the visitor must be sent
26
+ * elsewhere.
27
+ */
28
+ export declare function isMissingPageDocument({ hydratedSlug, requestedSlug }: NotFoundDetection): boolean;
29
+ //# sourceMappingURL=notFoundDocument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notFoundDocument.d.ts","sourceRoot":"","sources":["../src/notFoundDocument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,+CAA+C;AAC/C,eAAO,MAAM,cAAc,SAAS,CAAA;AAEpC,MAAM,WAAW,iBAAiB;IACjC,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAA;IACrB,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAA;CACpB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAIjG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.15.661",
4
+ "version": "1.15.663",
5
5
  "description": "Blox page builder library for drag-and-drop page building and static data management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",