mnfst-render 0.1.9 → 0.2.0

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.
@@ -702,12 +702,14 @@ function stripPrerenderedXDataDirectives(html) {
702
702
  function stripPrerenderDynamicBindings(html) {
703
703
  return html.replace(/<(\w+)([^>]*)>/g, (match, tagName, attrsStr) => {
704
704
  if (tagName.toLowerCase() === 'script') return match;
705
+ const isAnchor = tagName.toLowerCase() === 'a';
705
706
  const toStrip = new Set();
706
707
  const bindingRegex = /(?:^|\s)(?::|x-bind:)(\w+)=(?:"([^"]*)"|'([^']*)')/g;
707
708
  let m;
708
709
  while ((m = bindingRegex.exec(attrsStr)) !== null) {
709
710
  const attrName = (m[1] || '').toLowerCase();
710
- if (attrName === 'class' || attrName === 'style') continue;
711
+ // Keep href on anchors so prerendered static navigation stays valid.
712
+ if (attrName === 'class' || attrName === 'style' || (isAnchor && attrName === 'href')) continue;
711
713
  const val = (m[2] !== undefined ? m[2] : m[3]) || '';
712
714
  if (val.indexOf('$x') === -1) toStrip.add(attrName);
713
715
  }
@@ -1107,8 +1109,12 @@ async function main() {
1107
1109
  await new Promise((res) => staticServer.close(res));
1108
1110
  }
1109
1111
  }
1110
- const secs = ((Date.now() - startedAt) / 1000).toFixed(1);
1111
- process.stdout.write(`prerender: total time ${secs}s\n`);
1112
+ const elapsedMs = Date.now() - startedAt;
1113
+ const totalSeconds = Math.floor(elapsedMs / 1000);
1114
+ const hours = Math.floor(totalSeconds / 3600);
1115
+ const minutes = Math.floor((totalSeconds % 3600) / 60);
1116
+ const seconds = totalSeconds % 60;
1117
+ process.stdout.write(`prerender: total time ${hours}h ${minutes}m ${seconds}s\n`);
1112
1118
  }
1113
1119
 
1114
1120
  async function runPrerender(config) {
@@ -1281,6 +1287,24 @@ async function runPrerender(config) {
1281
1287
  });
1282
1288
  }).catch(() => { });
1283
1289
 
1290
+ // Ensure $route-dependent expressions are recalculated after locale/data stores settle.
1291
+ // This helps localized dynamic pages (e.g. /ko/articles/slug) compute prev/next links correctly.
1292
+ await page.evaluate(() => {
1293
+ try {
1294
+ const to = window.ManifestRoutingNavigation?.getCurrentRoute?.() ?? window.location.pathname;
1295
+ window.dispatchEvent(new CustomEvent('manifest:route-change', {
1296
+ detail: {
1297
+ from: to,
1298
+ to,
1299
+ normalizedPath: (typeof to === 'string' && to !== '/') ? to.replace(/^\/|\/$/g, '') : '/'
1300
+ }
1301
+ }));
1302
+ window.dispatchEvent(new PopStateEvent('popstate'));
1303
+ } catch {
1304
+ // no-op
1305
+ }
1306
+ }).catch(() => { });
1307
+
1284
1308
  // Optional extra delay so in-page async (e.g. fetch() in x-init for client logos) can complete before snapshot.
1285
1309
  if (config.waitAfterIdle > 0) {
1286
1310
  await new Promise((r) => setTimeout(r, config.waitAfterIdle));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst-render",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Render Manifest sites to static HTML for SEO",
5
5
  "type": "module",
6
6
  "bin": {