mnfst-render 0.5.19 → 0.5.21
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 +31 -3
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -661,6 +661,16 @@ function stripRuntimeTailwindArtifacts(html) {
|
|
|
661
661
|
return out;
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
+
// When tailwindcss isn't installed for the project, the prerender keeps the
|
|
665
|
+
// runtime-injected inline tailwind <style> block (it serves the static page
|
|
666
|
+
// for crawlers). But we must still strip `data-tailwind` from the loader
|
|
667
|
+
// script tag, otherwise the runtime tailwind plugin loads at page boot and
|
|
668
|
+
// injects ANOTHER tailwind <style> block AFTER prerender.utilities.css,
|
|
669
|
+
// breaking the cascade order so .hidden wins over .lg:col etc.
|
|
670
|
+
function stripDataTailwindAttr(html) {
|
|
671
|
+
return html.replace(/\sdata-tailwind(?:=(["']).*?\1)?/gi, '');
|
|
672
|
+
}
|
|
673
|
+
|
|
664
674
|
/** Manifest utilities plugin: <style id="utility-styles"> and <style id="utility-styles-critical"> */
|
|
665
675
|
function extractUtilityStyleBlocks(html) {
|
|
666
676
|
const blocks = [];
|
|
@@ -1409,7 +1419,11 @@ function generateLocaleVariantHtml({
|
|
|
1409
1419
|
// Standard Node.js post-processing (same sequence as processPath)
|
|
1410
1420
|
html = stripDevOnlyContent(html);
|
|
1411
1421
|
html = stripInjectedPluginScripts(html, config.root);
|
|
1412
|
-
if (tailwindBuilt)
|
|
1422
|
+
if (tailwindBuilt) {
|
|
1423
|
+
html = stripRuntimeTailwindArtifacts(html);
|
|
1424
|
+
} else {
|
|
1425
|
+
html = stripDataTailwindAttr(html);
|
|
1426
|
+
}
|
|
1413
1427
|
|
|
1414
1428
|
const pageUtilityBlocks = [];
|
|
1415
1429
|
if (bundleUtilities) {
|
|
@@ -1457,10 +1471,18 @@ function generateLocaleVariantHtml({
|
|
|
1457
1471
|
? `<meta name="manifest:router-base" content="${String(routerBasePath).replace(/"/g, '"')}">\n`
|
|
1458
1472
|
: '';
|
|
1459
1473
|
const routeDepth = fileSegments.length;
|
|
1474
|
+
// List of locales that actually have prerendered URL paths, so the runtime
|
|
1475
|
+
// localization plugin knows when a locale switch should navigate vs stay on
|
|
1476
|
+
// the current page (e.g. example switches in docs that use locale-aware data
|
|
1477
|
+
// sources without the host site being multilingual).
|
|
1478
|
+
const prerenderLocalesMeta =
|
|
1479
|
+
Array.isArray(locales) && locales.length > 0
|
|
1480
|
+
? `<meta name="manifest:prerender-locales" content="${locales.join(',')}">\n`
|
|
1481
|
+
: '';
|
|
1460
1482
|
|
|
1461
1483
|
html = html.replace(
|
|
1462
1484
|
'</head>',
|
|
1463
|
-
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}<meta name="manifest:prerendered" content="1">\n<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
1485
|
+
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}${prerenderLocalesMeta}<meta name="manifest:prerendered" content="1">\n<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
1464
1486
|
);
|
|
1465
1487
|
|
|
1466
1488
|
return { html, utilityBlocks: pageUtilityBlocks };
|
|
@@ -2922,6 +2944,8 @@ async function runPrerender(config) {
|
|
|
2922
2944
|
html = stripInjectedPluginScripts(html, config.root);
|
|
2923
2945
|
if (tailwindBuilt) {
|
|
2924
2946
|
html = stripRuntimeTailwindArtifacts(html);
|
|
2947
|
+
} else {
|
|
2948
|
+
html = stripDataTailwindAttr(html);
|
|
2925
2949
|
}
|
|
2926
2950
|
if (bundleUtilities) {
|
|
2927
2951
|
const extracted = extractUtilityStyleBlocks(html);
|
|
@@ -2966,9 +2990,13 @@ async function runPrerender(config) {
|
|
|
2966
2990
|
: '';
|
|
2967
2991
|
const routeDepth = fileSegments.length;
|
|
2968
2992
|
const prerenderedMeta = `<meta name="manifest:prerendered" content="1">\n`;
|
|
2993
|
+
const prerenderLocalesMeta =
|
|
2994
|
+
Array.isArray(locales) && locales.length > 0
|
|
2995
|
+
? `<meta name="manifest:prerender-locales" content="${locales.join(',')}">\n`
|
|
2996
|
+
: '';
|
|
2969
2997
|
html = html.replace(
|
|
2970
2998
|
'</head>',
|
|
2971
|
-
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}${prerenderedMeta}<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
2999
|
+
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}${prerenderLocalesMeta}${prerenderedMeta}<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
2972
3000
|
);
|
|
2973
3001
|
// (Hydration contract was already injected into the raw HTML before
|
|
2974
3002
|
// the Node.js post-processing pipeline ran, so it's already present.)
|