mnfst-render 0.2.4 → 0.2.5
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 +24 -0
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -1385,6 +1385,22 @@ async function runPrerender(config) {
|
|
|
1385
1385
|
const forceCollapse = explicit || inferred;
|
|
1386
1386
|
if (!forceCollapse) {
|
|
1387
1387
|
tpl.removeAttribute('data-prerender-collapsed');
|
|
1388
|
+
tpl.removeAttribute('data-prerender-static-generated');
|
|
1389
|
+
// Static mode: if prerender produced concrete siblings, mark template for removal later.
|
|
1390
|
+
const first = tpl.content?.firstElementChild;
|
|
1391
|
+
if (first) {
|
|
1392
|
+
const tag = first.tagName;
|
|
1393
|
+
let next = tpl.nextElementSibling;
|
|
1394
|
+
let generatedCount = 0;
|
|
1395
|
+
while (next) {
|
|
1396
|
+
if (next.tagName !== tag) break;
|
|
1397
|
+
generatedCount++;
|
|
1398
|
+
next = next.nextElementSibling;
|
|
1399
|
+
}
|
|
1400
|
+
if (generatedCount > 0) {
|
|
1401
|
+
tpl.setAttribute('data-prerender-static-generated', '1');
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1388
1404
|
return; // keep prerendered list for SEO
|
|
1389
1405
|
}
|
|
1390
1406
|
tpl.setAttribute('data-prerender-collapsed', '1');
|
|
@@ -1405,6 +1421,14 @@ async function runPrerender(config) {
|
|
|
1405
1421
|
});
|
|
1406
1422
|
});
|
|
1407
1423
|
|
|
1424
|
+
// Remove static x-for templates once static clones are generated.
|
|
1425
|
+
// This prevents Alpine from rendering duplicate lists at runtime.
|
|
1426
|
+
await page.evaluate(() => {
|
|
1427
|
+
document.querySelectorAll('template[x-for][data-prerender-static-generated="1"]').forEach((tpl) => {
|
|
1428
|
+
tpl.remove();
|
|
1429
|
+
});
|
|
1430
|
+
});
|
|
1431
|
+
|
|
1408
1432
|
// Remove orphan x-for clones that still reference loop-scope vars (e.g. image/index)
|
|
1409
1433
|
// outside their template scope. These throw Alpine errors in live static hosting.
|
|
1410
1434
|
await page.evaluate(() => {
|