mnfst-render 0.2.0 → 0.2.1
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/manifest.render.mjs +25 -3
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -1289,9 +1289,30 @@ async function runPrerender(config) {
|
|
|
1289
1289
|
|
|
1290
1290
|
// Ensure $route-dependent expressions are recalculated after locale/data stores settle.
|
|
1291
1291
|
// This helps localized dynamic pages (e.g. /ko/articles/slug) compute prev/next links correctly.
|
|
1292
|
-
await page.evaluate(() => {
|
|
1292
|
+
await page.evaluate(({ allLocales, currentLocale }) => {
|
|
1293
1293
|
try {
|
|
1294
|
-
const
|
|
1294
|
+
const localeList = Array.isArray(allLocales) ? allLocales : [];
|
|
1295
|
+
const store = (typeof Alpine !== 'undefined' && Alpine.store) ? Alpine.store('locale') : null;
|
|
1296
|
+
if (store) {
|
|
1297
|
+
if (!Array.isArray(store.available) || store.available.length === 0) {
|
|
1298
|
+
store.available = localeList.slice();
|
|
1299
|
+
} else {
|
|
1300
|
+
const merged = Array.from(new Set([...store.available, ...localeList]));
|
|
1301
|
+
store.available = merged;
|
|
1302
|
+
}
|
|
1303
|
+
if (currentLocale && typeof currentLocale === 'string') {
|
|
1304
|
+
store.current = currentLocale;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
const rawRoute = window.ManifestRoutingNavigation?.getCurrentRoute?.() ?? window.location.pathname;
|
|
1309
|
+
const clean = String(rawRoute || '/').replace(/^\/+|\/+$/g, '');
|
|
1310
|
+
const parts = clean ? clean.split('/') : [];
|
|
1311
|
+
const logical = parts.length > 0 && localeList.includes(parts[0])
|
|
1312
|
+
? '/' + parts.slice(1).join('/')
|
|
1313
|
+
: (clean ? '/' + clean : '/');
|
|
1314
|
+
const to = logical === '//' ? '/' : logical;
|
|
1315
|
+
|
|
1295
1316
|
window.dispatchEvent(new CustomEvent('manifest:route-change', {
|
|
1296
1317
|
detail: {
|
|
1297
1318
|
from: to,
|
|
@@ -1303,7 +1324,8 @@ async function runPrerender(config) {
|
|
|
1303
1324
|
} catch {
|
|
1304
1325
|
// no-op
|
|
1305
1326
|
}
|
|
1306
|
-
}).catch(() => { });
|
|
1327
|
+
}, { allLocales: locales, currentLocale }).catch(() => { });
|
|
1328
|
+
await page.waitForTimeout(60).catch(() => { });
|
|
1307
1329
|
|
|
1308
1330
|
// Optional extra delay so in-page async (e.g. fetch() in x-init for client logos) can complete before snapshot.
|
|
1309
1331
|
if (config.waitAfterIdle > 0) {
|