@koehler8/cms 1.0.0-beta.24 → 1.0.0-beta.26
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
|
@@ -136,13 +136,25 @@ export function planVariantJobs({ siteDir, config }) {
|
|
|
136
136
|
const baseName = parsed.name;
|
|
137
137
|
|
|
138
138
|
const outputs = [];
|
|
139
|
+
|
|
140
|
+
// Copy the source to the flat dir under its bare name. Components that
|
|
141
|
+
// reference assets by their bare path (`resolveAsset('img/logo.png')`,
|
|
142
|
+
// useResponsiveImage's `${basePath}.${format}` fallback) need the
|
|
143
|
+
// original present at `site/assets/img/{name}.{ext}`; without this,
|
|
144
|
+
// sites that migrate originals into _source/ break every bare-path
|
|
145
|
+
// lookup.
|
|
146
|
+
outputs.push({
|
|
147
|
+
kind: 'copy',
|
|
148
|
+
outPath: path.join(imgDir, subdir, parsed.base),
|
|
149
|
+
});
|
|
150
|
+
|
|
139
151
|
for (const width of config.widths) {
|
|
140
152
|
for (const format of config.formats) {
|
|
141
153
|
const ext = FORMAT_OUTPUT_EXT[format];
|
|
142
154
|
if (!ext) continue;
|
|
143
155
|
const outName = `${baseName}-${width}.${ext}`;
|
|
144
156
|
const outPath = path.join(imgDir, subdir, outName);
|
|
145
|
-
outputs.push({ width, format, outPath });
|
|
157
|
+
outputs.push({ kind: 'variant', width, format, outPath });
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
160
|
jobs.push({ sourcePath, outputs });
|
|
@@ -155,6 +167,11 @@ async function renderOutput(sourcePath, output, config) {
|
|
|
155
167
|
const { width, format, outPath } = output;
|
|
156
168
|
await fs.promises.mkdir(path.dirname(outPath), { recursive: true });
|
|
157
169
|
|
|
170
|
+
if (output.kind === 'copy') {
|
|
171
|
+
await fs.promises.copyFile(sourcePath, outPath);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
158
175
|
let pipeline = sharp(sourcePath, { failOn: 'truncated' }).rotate();
|
|
159
176
|
pipeline = pipeline.resize({ width, withoutEnlargement: true });
|
|
160
177
|
switch (format) {
|
|
@@ -414,6 +414,17 @@ const updateLocaleMenuPosition = () => {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
isLangOpen.value = false;
|
|
417
|
+
// Persist the user's explicit choice so it survives navigation to the
|
|
418
|
+
// unprefixed base-locale URL (`/`). The router guard only writes
|
|
419
|
+
// localStorage when a locale param is present in the URL — clicking
|
|
420
|
+
// the base locale navigates to `/` (no param), so the write must
|
|
421
|
+
// happen here instead. Also keeps loadConfigData's localStorage
|
|
422
|
+
// fallback in sync with the active selection.
|
|
423
|
+
if (!import.meta.env.SSR && typeof localStorage !== 'undefined') {
|
|
424
|
+
try {
|
|
425
|
+
localStorage.setItem('locale', locale);
|
|
426
|
+
} catch {}
|
|
427
|
+
}
|
|
417
428
|
};
|
|
418
429
|
|
|
419
430
|
onMounted(() => {
|
package/src/router/index.js
CHANGED
|
@@ -136,6 +136,19 @@ export function applyRouterGuards(router, localePrefixes = computeLocalePrefixes
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (!import.meta.env.SSR) {
|
|
139
|
+
// Browser-language auto-redirect on first visit only. If the user
|
|
140
|
+
// already has a stored locale preference (set by either an explicit
|
|
141
|
+
// dropdown click or a previous visit to a locale-prefixed URL),
|
|
142
|
+
// respect that — don't second-guess them with browser-language
|
|
143
|
+
// detection. This prevents the bug where clicking "EN" on /de
|
|
144
|
+
// navigates to / and the auto-detect bounces back to /de because
|
|
145
|
+
// the browser is set to German.
|
|
146
|
+
let storedPreference = '';
|
|
147
|
+
try {
|
|
148
|
+
storedPreference = (localStorage.getItem('locale') || '').toString().toLowerCase();
|
|
149
|
+
} catch {}
|
|
150
|
+
if (storedPreference) return;
|
|
151
|
+
|
|
139
152
|
const navLang = (navigator.language || navigator.userLanguage || '').toString();
|
|
140
153
|
const shortLang = normalizeLocale(navLang || '');
|
|
141
154
|
|