@koehler8/cms 1.0.0-beta.33 → 1.0.0-beta.34

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.33",
3
+ "version": "1.0.0-beta.34",
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",
@@ -130,14 +130,26 @@ const isHeaderCompact = ref(false);
130
130
  const currentLocale = ref('');
131
131
  const availableLocales = computed(() => siteLocales.map((code) => code.trim()).filter(Boolean));
132
132
 
133
- // The base locale is served at the unprefixed root path (`/`) — clicking
134
- // the dropdown item for it should NOT navigate to `/{baseLocale}` because
135
- // that URL doesn't pre-render and would 404. Build the link path
136
- // accordingly: base → `/`, others → `/{locale}`.
133
+ // Switching language keeps the visitor on the SAME page rather than bouncing
134
+ // them to the locale's home. Slugs are shared across locales, so take the
135
+ // current path, strip any leading non-base locale segment, and re-prefix with
136
+ // the target locale. The base locale is served unprefixed (`/path`); others at
137
+ // `/{locale}/path`. (`/{baseLocale}/path` doesn't pre-render and would 404,
138
+ // hence the base stays unprefixed.)
137
139
  const localeHref = (locale) => {
138
- if (locale === siteBaseLocale) return '/';
140
+ const segments = (route.path || '/').split('/').filter(Boolean);
141
+ if (segments.length) {
142
+ const first = segments[0].toLowerCase();
143
+ if (first !== siteBaseLocale && availableLocales.value.includes(first)) {
144
+ segments.shift();
145
+ }
146
+ }
147
+ const rest = segments.join('/');
139
148
  const slash = injectedSiteData.value?.site?.trailingSlash === true ? '/' : '';
140
- return `/${locale}${slash}`;
149
+ if (locale === siteBaseLocale) {
150
+ return rest ? `/${rest}${slash}` : '/';
151
+ }
152
+ return rest ? `/${locale}/${rest}${slash}` : `/${locale}${slash}`;
141
153
  };
142
154
  const localeLabels = {
143
155
  en: 'English',
@@ -231,6 +231,11 @@ export function usePageMeta({ siteData, currentPage, locale }) {
231
231
  }
232
232
 
233
233
  return {
234
+ // Reflect the page's locale on <html lang> during SSR/prerender so the
235
+ // on-disk HTML for /{locale}/... ships the right language (the router
236
+ // guard only sets this client-side, after hydration). Base-locale pages
237
+ // fall back to the configured base locale.
238
+ htmlAttrs: { lang: localeValue.value || configBaseLocale || 'en' },
234
239
  title: pageMetaTitle.value,
235
240
  meta,
236
241
  link,