mnfst-render 0.3.4 → 0.3.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 +15 -0
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -951,6 +951,20 @@ function stripRedundantImgSrcBindings(html) {
|
|
|
951
951
|
});
|
|
952
952
|
}
|
|
953
953
|
|
|
954
|
+
/**
|
|
955
|
+
* Manifest runtime replaces <x-*> component placeholders by fetching source .html, which wipes
|
|
956
|
+
* prerender-baked markup (stripped :style, expanded lists, etc.). Tag opens with data-pre-rendered
|
|
957
|
+
* are skipped by manifest.components.processor — required for static prerender output to hydrate correctly.
|
|
958
|
+
*/
|
|
959
|
+
function markPrerenderedManifestComponents(html) {
|
|
960
|
+
return html.replace(/<(x-[a-z][\w-]*)([^>]*)>/gi, (full, tag, attrs) => {
|
|
961
|
+
const a = attrs || '';
|
|
962
|
+
if (/\bdata-pre-rendered\s*=/i.test(a) || /\bdata-processed\s*=/i.test(a)) return full;
|
|
963
|
+
const spacer = /\S/.test(a) ? ' ' : '';
|
|
964
|
+
return `<${tag}${a}${spacer}data-pre-rendered="1">`;
|
|
965
|
+
});
|
|
966
|
+
}
|
|
967
|
+
|
|
954
968
|
// Remove empty inline mask-image styles emitted before data resolves
|
|
955
969
|
// (e.g. style="mask-image: url()"), while keeping any :style/x-bind:style bindings.
|
|
956
970
|
function stripEmptyInlineMaskStyles(html) {
|
|
@@ -2019,6 +2033,7 @@ async function runPrerender(config) {
|
|
|
2019
2033
|
const routeDepth = fileSegments.length;
|
|
2020
2034
|
const prerenderedMeta = `<meta name="manifest:prerendered" content="1">\n`;
|
|
2021
2035
|
html = html.replace('</head>', `${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${baseMeta}${prerenderedMeta}<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`);
|
|
2036
|
+
html = markPrerenderedManifestComponents(html);
|
|
2022
2037
|
mkdirSync(outDir, { recursive: true });
|
|
2023
2038
|
writeFileSync(outFile, html, 'utf8');
|
|
2024
2039
|
pushDebug({
|