@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
|
@@ -1300,6 +1300,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
return section;
|
|
1302
1302
|
}
|
|
1303
|
+
function computeDuplicateSiblingSortBoundaries(siblings) {
|
|
1304
|
+
const result = /* @__PURE__ */ new Map();
|
|
1305
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
1306
|
+
for (const sibling of siblings) {
|
|
1307
|
+
if (metaStr(sibling.seg.metadata, "type") !== "section") {
|
|
1308
|
+
continue;
|
|
1309
|
+
}
|
|
1310
|
+
const group = byPath.get(sibling.seg.section) ?? [];
|
|
1311
|
+
group.push(sibling);
|
|
1312
|
+
byPath.set(sibling.seg.section, group);
|
|
1313
|
+
}
|
|
1314
|
+
for (const [, group] of byPath) {
|
|
1315
|
+
if (group.length <= 1) {
|
|
1316
|
+
continue;
|
|
1317
|
+
}
|
|
1318
|
+
for (let i = 0; i < group.length; i++) {
|
|
1319
|
+
result.set(group[i], {
|
|
1320
|
+
lo: group[i].seg.sortOrder,
|
|
1321
|
+
hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
return result;
|
|
1326
|
+
}
|
|
1303
1327
|
function mergeChildrenByPosition(ctx, nav, sectionChildren) {
|
|
1304
1328
|
const leafNodes = [];
|
|
1305
1329
|
for (let i = 0; i < nav.length; i++) {
|
|
@@ -1354,12 +1378,15 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
1354
1378
|
children: mergeChildrenByPosition(ctx, nav, sectionChildren)
|
|
1355
1379
|
};
|
|
1356
1380
|
}
|
|
1357
|
-
function directChildApiPackages(parentSection, scopeSegs) {
|
|
1381
|
+
function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
|
|
1358
1382
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
1359
1383
|
return scopeSegs.filter((s) => {
|
|
1360
1384
|
if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
|
|
1361
1385
|
return false;
|
|
1362
1386
|
}
|
|
1387
|
+
if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1363
1390
|
const parent = parentSectionPath(s.seg.section);
|
|
1364
1391
|
if (parent === parentSection) {
|
|
1365
1392
|
return true;
|
|
@@ -1373,7 +1400,17 @@ function directChildApiPackages(parentSection, scopeSegs) {
|
|
|
1373
1400
|
function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix) {
|
|
1374
1401
|
const { seg, nav } = scoped;
|
|
1375
1402
|
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
1376
|
-
|
|
1403
|
+
let childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
|
|
1404
|
+
const samePathApiSiblings = scopeSegs.filter(
|
|
1405
|
+
(s) => s.seg.section === seg.section && s.seg.sortOrder !== seg.sortOrder && API_NODE_SEGMENT_TYPES.has(metaStr(s.seg.metadata, "type") ?? "")
|
|
1406
|
+
);
|
|
1407
|
+
const hasCollapsedGroups = samePathApiSiblings.length > 0;
|
|
1408
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") !== "apiReference") {
|
|
1409
|
+
const nextSibling = samePathApiSiblings.filter((s) => s.seg.sortOrder > seg.sortOrder).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder)[0];
|
|
1410
|
+
const lo = seg.sortOrder;
|
|
1411
|
+
const hi = nextSibling?.seg.sortOrder ?? Number.MAX_SAFE_INTEGER;
|
|
1412
|
+
childPackages = childPackages.filter((c) => c.seg.sortOrder > lo && c.seg.sortOrder < hi);
|
|
1413
|
+
}
|
|
1377
1414
|
const packageNodes = childPackages.map((child) => ({
|
|
1378
1415
|
node: apiPackageChildNode(
|
|
1379
1416
|
ctx,
|
|
@@ -1384,6 +1421,9 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
1384
1421
|
),
|
|
1385
1422
|
childIndex: metaNum(child.seg.metadata, "childIndex")
|
|
1386
1423
|
}));
|
|
1424
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") === "apiReference") {
|
|
1425
|
+
return [...leafNodes, ...packageNodes.map((p, i) => ({ node: p.node, pos: leafNodes.length + i }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
1426
|
+
}
|
|
1387
1427
|
const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
|
|
1388
1428
|
if (!hasChildIndex) {
|
|
1389
1429
|
return [...leafNodes, ...packageNodes.map((p) => ({ node: p.node, pos: Number.MAX_SAFE_INTEGER }))].sort((a, b) => a.pos - b.pos).map((p) => p.node);
|
|
@@ -1514,7 +1554,7 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
|
|
|
1514
1554
|
availability: metaAvailability(seg.metadata),
|
|
1515
1555
|
overviewPageId: overviewPageId != null ? PageId(overviewPageId) : void 0,
|
|
1516
1556
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
1517
|
-
paginated:
|
|
1557
|
+
paginated: metaBool(seg.metadata, "paginated"),
|
|
1518
1558
|
showErrors: metaBool(seg.metadata, "showErrors"),
|
|
1519
1559
|
hideTitle: metaBool(seg.metadata, "hideTitle"),
|
|
1520
1560
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : void 0,
|
|
@@ -1532,7 +1572,10 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
|
|
|
1532
1572
|
}
|
|
1533
1573
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1534
1574
|
});
|
|
1535
|
-
const
|
|
1575
|
+
const apiReferenceCount = scopeSegs.filter((candidate) => {
|
|
1576
|
+
return metaStr(candidate.seg.metadata, "type") === "apiReference" && metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1577
|
+
}).length;
|
|
1578
|
+
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ?? (apiReferenceCount === 1 ? candidates[0] : void 0);
|
|
1536
1579
|
return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : void 0;
|
|
1537
1580
|
}
|
|
1538
1581
|
function hasOwningApiReference(scoped, scopeSegs) {
|
|
@@ -1540,12 +1583,13 @@ function hasOwningApiReference(scoped, scopeSegs) {
|
|
|
1540
1583
|
if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
|
|
1541
1584
|
return false;
|
|
1542
1585
|
}
|
|
1543
|
-
|
|
1586
|
+
const candidates = scopeSegs.filter((candidate) => {
|
|
1544
1587
|
if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
|
|
1545
1588
|
return false;
|
|
1546
1589
|
}
|
|
1547
1590
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
1548
1591
|
});
|
|
1592
|
+
return candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) || candidates.length === 1;
|
|
1549
1593
|
}
|
|
1550
1594
|
function isNestedApiPackage(scoped, scopeSegs) {
|
|
1551
1595
|
if (metaStr(scoped.seg.metadata, "type") !== "apiPackage") {
|
|
@@ -1691,6 +1735,10 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1691
1735
|
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1692
1736
|
return false;
|
|
1693
1737
|
}
|
|
1738
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1739
|
+
if (depth === 0) {
|
|
1740
|
+
return false;
|
|
1741
|
+
}
|
|
1694
1742
|
const parent = parentSectionPath(sec);
|
|
1695
1743
|
if (parent === parentPath) {
|
|
1696
1744
|
return true;
|
|
@@ -1700,6 +1748,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1700
1748
|
}
|
|
1701
1749
|
return false;
|
|
1702
1750
|
}).sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1751
|
+
const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
|
|
1703
1752
|
return direct.map((s) => {
|
|
1704
1753
|
const type = metaStr(s.seg.metadata, "type");
|
|
1705
1754
|
const childIndex = metaNum(s.seg.metadata, "childIndex");
|
|
@@ -1709,10 +1758,14 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1709
1758
|
} else if (type === "changelog") {
|
|
1710
1759
|
node = changelogNode(ctx, s, changelogScopePrefix ?? scopePrefix);
|
|
1711
1760
|
} else {
|
|
1761
|
+
const boundary = siblingBoundaries.get(s);
|
|
1762
|
+
const childScopeSegs = boundary != null ? scopeSegs.filter(
|
|
1763
|
+
(candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi
|
|
1764
|
+
) : scopeSegs;
|
|
1712
1765
|
node = sectionNode(
|
|
1713
1766
|
ctx,
|
|
1714
1767
|
s,
|
|
1715
|
-
buildSectionTree(ctx,
|
|
1768
|
+
buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix),
|
|
1716
1769
|
scopePrefix
|
|
1717
1770
|
);
|
|
1718
1771
|
}
|
|
@@ -1726,11 +1779,16 @@ function computeSiblingSortBoundaries(ordered) {
|
|
|
1726
1779
|
for (const s of ordered) {
|
|
1727
1780
|
const type = metaStr(s.seg.metadata, "type");
|
|
1728
1781
|
const sec = s.seg.section;
|
|
1729
|
-
if (type !== "section"
|
|
1782
|
+
if (type !== "section") {
|
|
1783
|
+
continue;
|
|
1784
|
+
}
|
|
1785
|
+
if (sec === "") {
|
|
1786
|
+
rootSections.push(s);
|
|
1730
1787
|
continue;
|
|
1731
1788
|
}
|
|
1789
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1732
1790
|
const parent = parentSectionPath(sec);
|
|
1733
|
-
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1791
|
+
const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1734
1792
|
if (isRootLevel) {
|
|
1735
1793
|
rootSections.push(s);
|
|
1736
1794
|
}
|
|
@@ -1757,14 +1815,24 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1757
1815
|
const ordered = [...scopeSegs].sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1758
1816
|
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1759
1817
|
const annotated = [];
|
|
1760
|
-
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
|
|
1761
1818
|
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1819
|
+
const hasRootSection = ordered.some(
|
|
1820
|
+
(s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "" && (metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s))
|
|
1821
|
+
);
|
|
1762
1822
|
for (const s of ordered) {
|
|
1763
1823
|
const type = metaStr(s.seg.metadata, "type");
|
|
1764
1824
|
const sec = s.seg.section;
|
|
1765
1825
|
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1766
1826
|
continue;
|
|
1767
1827
|
}
|
|
1828
|
+
if (type === "apiPackage") {
|
|
1829
|
+
const hasApiRefSibling = ordered.some(
|
|
1830
|
+
(sib) => sib.seg.section === sec && metaStr(sib.seg.metadata, "type") === "apiReference"
|
|
1831
|
+
);
|
|
1832
|
+
if (hasApiRefSibling) {
|
|
1833
|
+
continue;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1768
1836
|
if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
|
|
1769
1837
|
continue;
|
|
1770
1838
|
}
|
|
@@ -1777,15 +1845,18 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1777
1845
|
}
|
|
1778
1846
|
continue;
|
|
1779
1847
|
}
|
|
1780
|
-
if (type === "section" && sec === "") {
|
|
1781
|
-
const
|
|
1848
|
+
if (type === "section" && sec === "" && hasRootSection) {
|
|
1849
|
+
const bounds = siblingBoundaries.get(s);
|
|
1850
|
+
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1851
|
+
const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
|
|
1782
1852
|
const node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1783
1853
|
annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
|
|
1784
1854
|
continue;
|
|
1785
1855
|
}
|
|
1856
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1786
1857
|
const parent = parentSectionPath(sec);
|
|
1787
|
-
const isRootLevel = parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1788
|
-
if (isRootLevel && hasRootSection && sec !== "") {
|
|
1858
|
+
const isRootLevel = depth === 0 || parent === "" || !sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "";
|
|
1859
|
+
if (isRootLevel && hasRootSection && sec !== "" && depth == null) {
|
|
1789
1860
|
continue;
|
|
1790
1861
|
}
|
|
1791
1862
|
if (isRootLevel) {
|
|
@@ -1797,12 +1868,9 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1797
1868
|
} else {
|
|
1798
1869
|
const bounds = siblingBoundaries.get(s);
|
|
1799
1870
|
const ownedSegs = bounds != null ? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi) : scopeSegs;
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix),
|
|
1804
|
-
scopePrefix
|
|
1805
|
-
);
|
|
1871
|
+
const isUnboundedSkipSlugSibling = sec === "" && metaNum(s.seg.metadata, "childIndex") != null && bounds == null;
|
|
1872
|
+
const sectionChildren = isUnboundedSkipSlugSibling ? [] : buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix);
|
|
1873
|
+
node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1806
1874
|
}
|
|
1807
1875
|
const isSharedSection = siblingBoundaries.size > 0 && scopePrefix !== "" && sec !== "" && !sec.startsWith(scopePrefix);
|
|
1808
1876
|
annotated.push({
|
|
@@ -1840,10 +1908,6 @@ function groupSidebarRootChildren(ctx, children) {
|
|
|
1840
1908
|
} else if (child.type === "section" && !child.collapsible) {
|
|
1841
1909
|
flushRun();
|
|
1842
1910
|
out.push(child);
|
|
1843
|
-
} else if (child.type === "changelog") {
|
|
1844
|
-
flushRun();
|
|
1845
|
-
run.push(child);
|
|
1846
|
-
flushRun();
|
|
1847
1911
|
} else {
|
|
1848
1912
|
run.push(child);
|
|
1849
1913
|
}
|
|
@@ -1958,7 +2022,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
|
|
|
1958
2022
|
const variantIndividualSlug = detailSlug(variant);
|
|
1959
2023
|
const variantSlug = variantIndividualSlug !== "" ? asSlug(slugjoin(scopePrefix, variantIndividualSlug)) : scopePrefix;
|
|
1960
2024
|
const metaPointsTo = metaStr(variant.metadata, "pointsTo");
|
|
1961
|
-
const children = buildSidebarRootChildren(ctx, variantSegs,
|
|
2025
|
+
const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
|
|
1962
2026
|
return {
|
|
1963
2027
|
type: "variant",
|
|
1964
2028
|
...withMetadataDefaults({
|
|
@@ -2360,6 +2424,7 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2360
2424
|
};
|
|
2361
2425
|
return node;
|
|
2362
2426
|
});
|
|
2427
|
+
markCrossProductCanonicalSlugs(children);
|
|
2363
2428
|
return {
|
|
2364
2429
|
type: "productgroup",
|
|
2365
2430
|
id: ctx.nodeId("productgroup"),
|
|
@@ -2371,6 +2436,32 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
2371
2436
|
children
|
|
2372
2437
|
};
|
|
2373
2438
|
}
|
|
2439
|
+
function markCrossProductCanonicalSlugs(productNodes) {
|
|
2440
|
+
const pageIdToCanonical = /* @__PURE__ */ new Map();
|
|
2441
|
+
const sorted = [...productNodes].sort((a, b) => {
|
|
2442
|
+
if (a.default !== b.default) {
|
|
2443
|
+
return a.default ? -1 : 1;
|
|
2444
|
+
}
|
|
2445
|
+
return 0;
|
|
2446
|
+
});
|
|
2447
|
+
for (const product of sorted) {
|
|
2448
|
+
traverseDF(product, (child) => {
|
|
2449
|
+
if (hasMetadata(child) && isPage(child)) {
|
|
2450
|
+
const pid = getPageId(child);
|
|
2451
|
+
if (pid == null) {
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
const key = `pid:${pid}`;
|
|
2455
|
+
const canonical = pageIdToCanonical.get(key);
|
|
2456
|
+
if (canonical != null && !product.default) {
|
|
2457
|
+
child.canonicalSlug = canonical;
|
|
2458
|
+
} else if (canonical == null) {
|
|
2459
|
+
pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2374
2465
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2375
2466
|
0 && (module.exports = {
|
|
2376
2467
|
apiLeafNodeFromNavRoute,
|