mnfst-render 0.5.45 → 0.5.46
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 +28 -4
- package/package.json +1 -1
package/manifest.render.mjs
CHANGED
|
@@ -840,20 +840,43 @@ function discoverDataPaths(manifest, rootDir, wildcardBases = [], locales = [])
|
|
|
840
840
|
return wildcardBases.some((base) => rest.startsWith(base + '/'));
|
|
841
841
|
}
|
|
842
842
|
|
|
843
|
+
// A source mounts under the wildcard route named after it: `docs/*` for key
|
|
844
|
+
// `docs`, or a nested base ending in the key (`docs/framework/*` for key
|
|
845
|
+
// `framework`).
|
|
846
|
+
const mounts = new Map();
|
|
847
|
+
function mountFor(sourceKey) {
|
|
848
|
+
if (!sourceKey) return null;
|
|
849
|
+
if (mounts.has(sourceKey)) return mounts.get(sourceKey);
|
|
850
|
+
let mount = null;
|
|
851
|
+
if (wildcardBases.includes(sourceKey)) mount = sourceKey;
|
|
852
|
+
else {
|
|
853
|
+
const nested = wildcardBases.filter((b) => b.split('/').pop() === sourceKey);
|
|
854
|
+
if (nested.length === 1) {
|
|
855
|
+
mount = nested[0];
|
|
856
|
+
process.stderr.write(`prerender: data source "${sourceKey}" mounts under ${mount}/*\n`);
|
|
857
|
+
} else if (nested.length > 1) {
|
|
858
|
+
process.stderr.write(`prerender: data source "${sourceKey}" matches ${nested.map((b) => b + '/*').join(', ')}; not mounted (ambiguous)\n`);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
mounts.set(sourceKey, mount);
|
|
862
|
+
return mount;
|
|
863
|
+
}
|
|
864
|
+
|
|
843
865
|
function expandCandidates(rawPath, sourceKey) {
|
|
844
866
|
const p = String(rawPath || '').replace(/^\/+|\/+$/g, '');
|
|
845
867
|
if (!p) return [];
|
|
846
868
|
const candidates = [p];
|
|
847
869
|
if (wildcardBases.length === 0) return candidates;
|
|
848
|
-
|
|
870
|
+
const mount = mountFor(sourceKey);
|
|
871
|
+
if (!mount) return candidates;
|
|
849
872
|
const parts = p.split('/');
|
|
850
873
|
const hasLocalePrefix = parts.length > 1 && localeSet.has(parts[0].toLowerCase());
|
|
851
874
|
if (hasLocalePrefix) {
|
|
852
875
|
const locale = parts[0];
|
|
853
876
|
const rest = parts.slice(1).join('/');
|
|
854
|
-
if (rest && !rest.startsWith(
|
|
855
|
-
} else if (!p.startsWith(
|
|
856
|
-
candidates.push(`${
|
|
877
|
+
if (rest && !rest.startsWith(mount + '/')) candidates.push(`${locale}/${mount}/${rest}`);
|
|
878
|
+
} else if (!p.startsWith(mount + '/')) {
|
|
879
|
+
candidates.push(`${mount}/${p}`);
|
|
857
880
|
}
|
|
858
881
|
return candidates;
|
|
859
882
|
}
|
|
@@ -5462,6 +5485,7 @@ if (_isDirectEntry) {
|
|
|
5462
5485
|
// Exports for the CLI bin script and for unit testing.
|
|
5463
5486
|
export {
|
|
5464
5487
|
main,
|
|
5488
|
+
discoverRoutes,
|
|
5465
5489
|
acquireOutputLock,
|
|
5466
5490
|
outputLockPath,
|
|
5467
5491
|
markPrerenderedManifestComponents,
|