@fern-api/fdr-sdk 1.2.42-b174eece86 → 1.2.42-e01a8637c3
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/dist/js/client/FdrClient.js +1 -0
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +1 -0
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/index.js +1 -0
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +1 -0
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +115 -24
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +115 -24
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/js/orpc-client.js +1 -0
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +1 -0
- package/dist/js/orpc-client.mjs.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js +267 -0
- package/dist/navigation/__test__/ledger-root-builder.crossProductDedup.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js +306 -0
- package/dist/navigation/__test__/ledger-root-builder.ledgerParity.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js +102 -0
- package/dist/navigation/__test__/ledger-root-builder.rootChildOrder.test.js.map +1 -1
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js +273 -0
- package/dist/navigation/__test__/ledger-root-builder.sidebarDepth.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js +234 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.js.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +2 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +1 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js +256 -0
- package/dist/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.js.map +1 -0
- package/dist/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/navigation/ledger-root-builder.js +207 -35
- package/dist/navigation/ledger-root-builder.js.map +1 -1
- package/dist/orpc-client/docs-ledger/contract.d.ts +9 -0
- package/dist/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/dist/orpc-client/docs-ledger/contract.js +1 -0
- package/dist/orpc-client/docs-ledger/contract.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.crossProductDedup.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.ledgerParity.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.sidebarDepth.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugGroupOrdering.test.d.ts.map +1 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts +2 -0
- package/dist/types/navigation/__test__/ledger-root-builder.skipSlugSiblingSection.test.d.ts.map +1 -0
- package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/contract.d.ts +9 -0
- package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1259,6 +1259,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
|
|
|
1259
1259
|
}
|
|
1260
1260
|
return section;
|
|
1261
1261
|
}
|
|
1262
|
+
function computeDuplicateSiblingSortBoundaries(siblings) {
|
|
1263
|
+
const result = /* @__PURE__ */ new Map();
|
|
1264
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1265
|
+
for (const sibling of siblings) {
|
|
1266
|
+
if (metaStr(sibling.seg.metadata, "type") !== "section") {
|
|
1267
|
+
continue;
|
|
1268
|
+
}
|
|
1269
|
+
const group = byPath.get(sibling.seg.section) ?? [];
|
|
1270
|
+
group.push(sibling);
|
|
1271
|
+
byPath.set(sibling.seg.section, group);
|
|
1272
|
+
}
|
|
1273
|
+
for (const [, group] of byPath) {
|
|
1274
|
+
if (group.length <= 1) {
|
|
1275
|
+
continue;
|
|
1276
|
+
}
|
|
1277
|
+
for (let i = 0; i < group.length; i++) {
|
|
1278
|
+
result.set(group[i], {
|
|
1279
|
+
lo: group[i].seg.sortOrder,
|
|
1280
|
+
hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
return result;
|
|
1285
|
+
}
|
|
1262
1286
|
function mergeChildrenByPosition(ctx, nav, sectionChildren) {
|
|
1263
1287
|
const leafNodes = [];
|
|
1264
1288
|
for (let i = 0; i < nav.length; i++) {
|
|
@@ -1313,12 +1337,15 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
1313
1337
|
children: mergeChildrenByPosition(ctx, nav, sectionChildren)
|
|
1314
1338
|
};
|
|
1315
1339
|
}
|
|
1316
|
-
function directChildApiPackages(parentSection, scopeSegs) {
|
|
1340
|
+
function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
|
|
1317
1341
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
1318
1342
|
return scopeSegs.filter((s) => {
|
|
1319
1343
|
if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
|
|
1320
1344
|
return false;
|
|
1321
1345
|
}
|
|
1346
|
+
if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
|
|
1347
|
+
return false;
|
|
1348
|
+
}
|
|
1322
1349
|
const parent = parentSectionPath(s.seg.section);
|
|
1323
1350
|
if (parent === parentSection) {
|
|
1324
1351
|
return true;
|
|
@@ -1332,7 +1359,17 @@ function directChildApiPackages(parentSection, scopeSegs) {
|
|
|
1332
1359
|
function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
|
|
1333
1360
|
const { seg, nav } = scoped;
|
|
1334
1361
|
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
1335
|
-
|
|
1362
|
+
let childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
|
|
1363
|
+
const samePathApiSiblings = scopeSegs.filter(
|
|
1364
|
+
(s) => s.seg.section === seg.section && s.seg.sortOrder !== seg.sortOrder && API_NODE_SEGMENT_TYPES.has(metaStr(s.seg.metadata, "type") ?? "")
|
|
1365
|
+
);
|
|
1366
|
+
const hasCollapsedGroups = samePathApiSiblings.length > 0;
|
|
1367
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") !== "apiReference") {
|
|
1368
|
+
const nextSibling = samePathApiSiblings.filter((s) => s.seg.sortOrder > seg.sortOrder).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder)[0];
|
|
1369
|
+
const lo = seg.sortOrder;
|
|
1370
|
+
const hi = nextSibling?.seg.sortOrder ?? Number.MAX_SAFE_INTEGER;
|
|
1371
|
+
childPackages = childPackages.filter((c) => c.seg.sortOrder > lo && c.seg.sortOrder < hi);
|
|
1372
|
+
}
|
|
1336
1373
|
const packageNodes = childPackages.map((child) => ({
|
|
1337
1374
|
node: apiPackageChildNode(
|
|
1338
1375
|
ctx,
|
|
@@ -1343,6 +1380,9 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
1343
1380
|
),
|
|
1344
1381
|
childIndex: metaNum(child.seg.metadata, "childIndex")
|
|
1345
1382
|
}));
|
|
1383
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") === "apiReference") {
|
|
1384
|
+
return [...leafNodes, ...packageNodes.map((p, i) => ({ node: p.node, pos: leafNodes.length + i }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
1385
|
+
}
|
|
1346
1386
|
const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
|
|
1347
1387
|
if (!hasChildIndex) {
|
|
1348
1388
|
return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
@@ -1473,7 +1513,7 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
|
|
|
1473
1513
|
availability: metaAvailability(seg.metadata),
|
|
1474
1514
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1475
1515
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1476
|
-
paginated:
|
|
1516
|
+
paginated: metaBool(seg.metadata, "paginated"),
|
|
1477
1517
|
showErrors: metaBool(seg.metadata, "showErrors"),
|
|
1478
1518
|
hideTitle: metaBool(seg.metadata, "hideTitle"),
|
|
1479
1519
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
@@ -1491,7 +1531,10 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
|
|
|
1491
1531
|
}
|
|
1492
1532
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1493
1533
|
});
|
|
1494
|
-
const
|
|
1534
|
+
const apiReferenceCount = scopeSegs.filter((candidate) => {
|
|
1535
|
+
return metaStr(candidate.seg.metadata, "type") === "apiReference" && metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1536
|
+
}).length;
|
|
1537
|
+
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? (apiReferenceCount === 1 ? candidates[0] : void 0);
|
|
1495
1538
|
return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : void 0;
|
|
1496
1539
|
}
|
|
1497
1540
|
function hasOwningApiReference(scoped, scopeSegs) {
|
|
@@ -1499,12 +1542,13 @@ function hasOwningApiReference(scoped, scopeSegs) {
|
|
|
1499
1542
|
if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
|
|
1500
1543
|
return false;
|
|
1501
1544
|
}
|
|
1502
|
-
|
|
1545
|
+
const candidates = scopeSegs.filter((candidate) => {
|
|
1503
1546
|
if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
|
|
1504
1547
|
return false;
|
|
1505
1548
|
}
|
|
1506
1549
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1507
1550
|
});
|
|
1551
|
+
return candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) || candidates.length === 1;
|
|
1508
1552
|
}
|
|
1509
1553
|
function isNestedApiPackage(scoped, scopeSegs) {
|
|
1510
1554
|
if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
|
|
@@ -1650,6 +1694,10 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1650
1694
|
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1651
1695
|
return false;
|
|
1652
1696
|
}
|
|
1697
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1698
|
+
if (depth === 0) {
|
|
1699
|
+
return false;
|
|
1700
|
+
}
|
|
1653
1701
|
const parent = parentSectionPath(sec);
|
|
1654
1702
|
if (parent === parentPath) {
|
|
1655
1703
|
return true;
|
|
@@ -1659,6 +1707,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1659
1707
|
}
|
|
1660
1708
|
return false;
|
|
1661
1709
|
}).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1710
|
+
const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
|
|
1662
1711
|
return direct.map((s) => {
|
|
1663
1712
|
const type = metaStr(s.seg.metadata, "type");
|
|
1664
1713
|
const childIndex = metaNum(s.seg.metadata, "childIndex");
|
|
@@ -1668,10 +1717,14 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1668
1717
|
} else if (type === "changelog") {
|
|
1669
1718
|
node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
|
|
1670
1719
|
} else {
|
|
1720
|
+
const boundary = siblingBoundaries.get(s);
|
|
1721
|
+
const childScopeSegs = boundary != null ? scopeSegs.filter(
|
|
1722
|
+
(candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
|
|
1723
|
+
) : scopeSegs;
|
|
1671
1724
|
node = sectionNode(
|
|
1672
1725
|
ctx,
|
|
1673
1726
|
s,
|
|
1674
|
-
buildSectionTree(ctx,
|
|
1727
|
+
buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
|
|
1675
1728
|
scopePrefix
|
|
1676
1729
|
);
|
|
1677
1730
|
}
|
|
@@ -1685,11 +1738,16 @@ function computeSiblingSortBoundaries(ordered) {
|
|
|
1685
1738
|
for (const s of ordered) {
|
|
1686
1739
|
const type = metaStr(s.seg.metadata, "type");
|
|
1687
1740
|
const sec = s.seg.section;
|
|
1688
|
-
if (type !== "section"
|
|
1741
|
+
if (type !== "section") {
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
if (sec === "") {
|
|
1745
|
+
rootSections.push(s);
|
|
1689
1746
|
continue;
|
|
1690
1747
|
}
|
|
1748
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1691
1749
|
const parent = parentSectionPath(sec);
|
|
1692
|
-
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1750
|
+
const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1693
1751
|
if (isRootLevel) {
|
|
1694
1752
|
rootSections.push(s);
|
|
1695
1753
|
}
|
|
@@ -1716,14 +1774,24 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1716
1774
|
const ordered = [...scopeSegs].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1717
1775
|
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1718
1776
|
const annotated = [];
|
|
1719
|
-
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
|
|
1720
1777
|
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1778
|
+
const hasRootSection = ordered.some(
|
|
1779
|
+
(s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && (metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s))
|
|
1780
|
+
);
|
|
1721
1781
|
for (const s of ordered) {
|
|
1722
1782
|
const type = metaStr(s.seg.metadata, "type");
|
|
1723
1783
|
const sec = s.seg.section;
|
|
1724
1784
|
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1725
1785
|
continue;
|
|
1726
1786
|
}
|
|
1787
|
+
if (type === "apiPackage") {
|
|
1788
|
+
const hasApiRefSibling = ordered.some(
|
|
1789
|
+
(sib) => sib.seg.section === sec && metaStr(sib.seg.metadata, "type") === "apiReference"
|
|
1790
|
+
);
|
|
1791
|
+
if (hasApiRefSibling) {
|
|
1792
|
+
continue;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1727
1795
|
if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
|
|
1728
1796
|
continue;
|
|
1729
1797
|
}
|
|
@@ -1736,15 +1804,18 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1736
1804
|
}
|
|
1737
1805
|
continue;
|
|
1738
1806
|
}
|
|
1739
|
-
if (type === "section" && sec === "") {
|
|
1740
|
-
const
|
|
1807
|
+
if (type === "section" && sec === "" && hasRootSection) {
|
|
1808
|
+
const bounds = siblingBoundaries.get(s);
|
|
1809
|
+
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1810
|
+
const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
|
|
1741
1811
|
const node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1742
1812
|
annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
|
|
1743
1813
|
continue;
|
|
1744
1814
|
}
|
|
1815
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1745
1816
|
const parent = parentSectionPath(sec);
|
|
1746
|
-
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1747
|
-
if (isRootLevel && hasRootSection && sec !== "") {
|
|
1817
|
+
const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1818
|
+
if (isRootLevel && hasRootSection && sec !== "" && depth == null) {
|
|
1748
1819
|
continue;
|
|
1749
1820
|
}
|
|
1750
1821
|
if (isRootLevel) {
|
|
@@ -1756,12 +1827,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1756
1827
|
} else {
|
|
1757
1828
|
const bounds = siblingBoundaries.get(s);
|
|
1758
1829
|
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix),
|
|
1763
|
-
scopePrefix
|
|
1764
|
-
);
|
|
1830
|
+
const isUnboundedSkipSlugSibling = sec === "" && metaNum(s.seg.metadata, "childIndex") != null && bounds == null;
|
|
1831
|
+
const sectionChildren = isUnboundedSkipSlugSibling ? [] : buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix);
|
|
1832
|
+
node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1765
1833
|
}
|
|
1766
1834
|
const isSharedSection = siblingBoundaries.size > 0 && scopePrefix !== "" && sec !== "" && !sec.startsWith(scopePrefix);
|
|
1767
1835
|
annotated.push({
|
|
@@ -1799,10 +1867,6 @@ function groupSidebarRootChildren(ctx, children) {
|
|
|
1799
1867
|
} else if (child.type === "section" && !child.collapsible) {
|
|
1800
1868
|
flushRun();
|
|
1801
1869
|
out.push(child);
|
|
1802
|
-
} else if (child.type === "changelog") {
|
|
1803
|
-
flushRun();
|
|
1804
|
-
run.push(child);
|
|
1805
|
-
flushRun();
|
|
1806
1870
|
} else {
|
|
1807
1871
|
run.push(child);
|
|
1808
1872
|
}
|
|
@@ -1917,7 +1981,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
|
|
|
1917
1981
|
const variantIndividualSlug = detailSlug(variant);
|
|
1918
1982
|
const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
|
|
1919
1983
|
const metaPointsTo = metaStr(variant.metadata, "pointsTo");
|
|
1920
|
-
const children = buildSidebarRootChildren(ctx, variantSegs,
|
|
1984
|
+
const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
|
|
1921
1985
|
return {
|
|
1922
1986
|
type: "variant",
|
|
1923
1987
|
...withMetadataDefaults({
|
|
@@ -2319,6 +2383,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2319
2383
|
};
|
|
2320
2384
|
return node;
|
|
2321
2385
|
});
|
|
2386
|
+
markCrossProductCanonicalSlugs(children);
|
|
2322
2387
|
return {
|
|
2323
2388
|
type: "productgroup",
|
|
2324
2389
|
id: ctx.nodeId("productgroup"),
|
|
@@ -2330,6 +2395,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2330
2395
|
children
|
|
2331
2396
|
};
|
|
2332
2397
|
}
|
|
2398
|
+
function markCrossProductCanonicalSlugs(productNodes) {
|
|
2399
|
+
const pageIdToCanonical = /* @__PURE__ */ new Map();
|
|
2400
|
+
const sorted = [...productNodes].sort((a, b) => {
|
|
2401
|
+
if (a.default !== b.default) {
|
|
2402
|
+
return a.default ? -1 : 1;
|
|
2403
|
+
}
|
|
2404
|
+
return 0;
|
|
2405
|
+
});
|
|
2406
|
+
for (const product of sorted) {
|
|
2407
|
+
traverseDF(product, (child) => {
|
|
2408
|
+
if (hasMetadata(child) && isPage(child)) {
|
|
2409
|
+
const pid = getPageId(child);
|
|
2410
|
+
if (pid == null) {
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
const key = `pid:${pid}`;
|
|
2414
|
+
const canonical = pageIdToCanonical.get(key);
|
|
2415
|
+
if (canonical != null && !product.default) {
|
|
2416
|
+
child.canonicalSlug = canonical;
|
|
2417
|
+
} else if (canonical == null) {
|
|
2418
|
+
pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2333
2424
|
export {
|
|
2334
2425
|
apiLeafNodeFromNavRoute,
|
|
2335
2426
|
buildFullRootFromSegments,
|