mnfst-render 0.5.20 → 0.5.22
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 +38 -2
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -701,6 +701,7 @@ function injectBeforeHeadClose(html, snippet) {
|
|
|
701
701
|
return out.replace(/<\/head>/i, `${snippet}\n</head>`);
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
+
|
|
704
705
|
function indexHtmlUsesTailwind(rootDir) {
|
|
705
706
|
const indexPath = join(rootDir, 'index.html');
|
|
706
707
|
if (!existsSync(indexPath)) return false;
|
|
@@ -814,6 +815,29 @@ function runTailwindCliForPrerender(rootDir, outputDir, pre) {
|
|
|
814
815
|
console.error('prerender: Tailwind CLI did not produce prerender.tailwind.css');
|
|
815
816
|
return false;
|
|
816
817
|
}
|
|
818
|
+
// Strip Tailwind preflight rules that conflict with Manifest's element-level
|
|
819
|
+
// resets. Tailwind's `hr { height: 0; border-top-width: 1px }` would win on
|
|
820
|
+
// specificity over Manifest's `:where(hr) {...}` reset (same `@layer base`,
|
|
821
|
+
// higher specificity), even when Manifest CSS loads after Tailwind. Removing
|
|
822
|
+
// the specific conflicting rules here is surgical: Tailwind's other utility
|
|
823
|
+
// classes (mt-6, md:hidden, etc.) keep their normal `@layer utilities`
|
|
824
|
+
// behaviour and continue to override Manifest's `*` reset as expected.
|
|
825
|
+
try {
|
|
826
|
+
const compiled = readFileSync(outCss, 'utf8');
|
|
827
|
+
// Inside Tailwind's `@layer base { ... }` block, remove the bare `hr { ... }`
|
|
828
|
+
// declaration only. Other element resets in the same layer don't conflict
|
|
829
|
+
// with Manifest's `:where()` resets (they target other elements or rely on
|
|
830
|
+
// Manifest's resets winning later in source order at equal specificity).
|
|
831
|
+
const stripped = compiled.replace(
|
|
832
|
+
/(\s*)hr\s*\{\s*height:\s*0;\s*color:\s*inherit;\s*border-top-width:\s*1px;?\s*\}/g,
|
|
833
|
+
''
|
|
834
|
+
);
|
|
835
|
+
if (stripped !== compiled) {
|
|
836
|
+
writeFileSync(outCss, stripped, 'utf8');
|
|
837
|
+
}
|
|
838
|
+
} catch (e) {
|
|
839
|
+
console.warn('prerender: failed to strip conflicting Tailwind preflight rules:', e?.message || e);
|
|
840
|
+
}
|
|
817
841
|
process.stdout.write(`prerender: wrote ${relative(rootDir, outCss)}\n`);
|
|
818
842
|
return true;
|
|
819
843
|
}
|
|
@@ -1471,10 +1495,18 @@ function generateLocaleVariantHtml({
|
|
|
1471
1495
|
? `<meta name="manifest:router-base" content="${String(routerBasePath).replace(/"/g, '"')}">\n`
|
|
1472
1496
|
: '';
|
|
1473
1497
|
const routeDepth = fileSegments.length;
|
|
1498
|
+
// List of locales that actually have prerendered URL paths, so the runtime
|
|
1499
|
+
// localization plugin knows when a locale switch should navigate vs stay on
|
|
1500
|
+
// the current page (e.g. example switches in docs that use locale-aware data
|
|
1501
|
+
// sources without the host site being multilingual).
|
|
1502
|
+
const prerenderLocalesMeta =
|
|
1503
|
+
Array.isArray(locales) && locales.length > 0
|
|
1504
|
+
? `<meta name="manifest:prerender-locales" content="${locales.join(',')}">\n`
|
|
1505
|
+
: '';
|
|
1474
1506
|
|
|
1475
1507
|
html = html.replace(
|
|
1476
1508
|
'</head>',
|
|
1477
|
-
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}<meta name="manifest:prerendered" content="1">\n<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
1509
|
+
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}${prerenderLocalesMeta}<meta name="manifest:prerendered" content="1">\n<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
1478
1510
|
);
|
|
1479
1511
|
|
|
1480
1512
|
return { html, utilityBlocks: pageUtilityBlocks };
|
|
@@ -2982,9 +3014,13 @@ async function runPrerender(config) {
|
|
|
2982
3014
|
: '';
|
|
2983
3015
|
const routeDepth = fileSegments.length;
|
|
2984
3016
|
const prerenderedMeta = `<meta name="manifest:prerendered" content="1">\n`;
|
|
3017
|
+
const prerenderLocalesMeta =
|
|
3018
|
+
Array.isArray(locales) && locales.length > 0
|
|
3019
|
+
? `<meta name="manifest:prerender-locales" content="${locales.join(',')}">\n`
|
|
3020
|
+
: '';
|
|
2985
3021
|
html = html.replace(
|
|
2986
3022
|
'</head>',
|
|
2987
|
-
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}${prerenderedMeta}<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
3023
|
+
`${canonicalHreflang}${injectOgLocale ? ogLocale : ''}${routeMeta}${baseMeta}${prerenderLocalesMeta}${prerenderedMeta}<meta name="manifest:router-base-depth" content="${routeDepth}">\n</head>`
|
|
2988
3024
|
);
|
|
2989
3025
|
// (Hydration contract was already injected into the raw HTML before
|
|
2990
3026
|
// the Node.js post-processing pipeline ran, so it's already present.)
|