@koehler8/cms 1.0.0-beta.36 → 1.0.0-beta.37

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,6 @@
1
1
  {
2
2
  "name": "@koehler8/cms",
3
- "version": "1.0.0-beta.36",
3
+ "version": "1.0.0-beta.37",
4
4
  "description": "Vertex CMS — lightweight, config-driven Vue 3 framework with theming, extensions, and SSG support",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/main.js CHANGED
@@ -135,6 +135,21 @@ export function createCmsApp() {
135
135
  };
136
136
 
137
137
  const extractCurrentRoute = () => {
138
+ // During SSG, vite-ssg passes the route being pre-rendered as a string
139
+ // on `ctx.routePath` and only pushes the router AFTER this setup fn runs
140
+ // — so `router.currentRoute` is still vue-router's START_LOCATION ('/')
141
+ // here, identically on every page. Resolve `routePath` through the router
142
+ // (a pure match, no navigation) to recover the real path + `params.locale`.
143
+ // Without this, `resolveCurrentPageId` sees '/' for every route, so the
144
+ // payload trim targets the wrong page — or, when '/' is ambiguous, none.
145
+ const routePath = ctx?.routePath;
146
+ if (typeof routePath === 'string' && routePath) {
147
+ try {
148
+ return router.resolve(routePath);
149
+ } catch {
150
+ return { path: routePath, params: {} };
151
+ }
152
+ }
138
153
  if (ctx?.route) {
139
154
  return ctx.route;
140
155
  }
@@ -70,8 +70,24 @@ export function resolvePageIdForRoute(config, routePath, localeParam) {
70
70
  (typeof p === 'string' ? p : '/').replace(/\/+/g, '/').replace(/\/+$/, '') || '/';
71
71
  target = normalize(target);
72
72
  const pages = (config && config.pages) || {};
73
- const matches = Object.entries(pages).filter(([, data]) => {
74
- const pagePath = data && typeof data.path === 'string' && data.path.trim() ? data.path : '/';
73
+
74
+ // The SSG pre-renders `/404` from a site's custom `pages/404.json` (mirrors
75
+ // usePageConfig.selectPage's `/404` → `404` mapping). That page is
76
+ // conventionally path-less, so it can't be matched by `path` below — map the
77
+ // route to it directly. It is also deliberately NOT treated as living at `/`
78
+ // (see the id === '404' guard in the matcher) so it never collides with
79
+ // `home` there — the collision that otherwise makes `/` ambiguous on any
80
+ // site shipping a custom 404 page, suppressing the home-page trim.
81
+ const notFound = pages['404'];
82
+ const notFoundPathless = notFound && !(typeof notFound.path === 'string' && notFound.path.trim());
83
+ if (target === '/404' && notFoundPathless) return '404';
84
+
85
+ const matches = Object.entries(pages).filter(([id, data]) => {
86
+ const hasPath = data && typeof data.path === 'string' && data.path.trim();
87
+ // A page with no explicit `path` conventionally lives at `/` (home). The
88
+ // SSG-only `404` page is the exception: it is served at `/404`, never `/`.
89
+ const pagePath = hasPath ? data.path : (id === '404' ? null : '/');
90
+ if (pagePath === null) return false;
75
91
  return normalize(pagePath) === target;
76
92
  });
77
93
  return matches.length === 1 ? matches[0][0] : null;