@fern-api/fdr-sdk 1.2.42-0c024f5b0d → 1.2.42-19c9e28733
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 +13 -0
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +13 -0
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/index.js +13 -0
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +13 -0
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +211 -39
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +211 -39
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/js/orpc-client.js +60 -0
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +59 -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.metadataPreservation.test.js +109 -4
- package/dist/navigation/__test__/ledger-root-builder.metadataPreservation.test.js.map +1 -1
- 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 +440 -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 +510 -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 +330 -45
- package/dist/navigation/ledger-root-builder.js.map +1 -1
- package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts +2 -0
- package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts.map +1 -0
- package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.js +153 -0
- package/dist/orpc-client/docs-ledger/__test__/config-files.navFiles.test.js.map +1 -0
- package/dist/orpc-client/docs-ledger/config-files.d.ts +8 -0
- package/dist/orpc-client/docs-ledger/config-files.d.ts.map +1 -1
- package/dist/orpc-client/docs-ledger/config-files.js +69 -0
- package/dist/orpc-client/docs-ledger/config-files.js.map +1 -1
- package/dist/orpc-client/docs-ledger/contract.d.ts +433 -28
- package/dist/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/dist/orpc-client/docs-ledger/contract.js +15 -0
- package/dist/orpc-client/docs-ledger/contract.js.map +1 -1
- package/dist/orpc-client/docs-ledger/ledger-manifest.d.ts +92 -0
- package/dist/orpc-client/docs-ledger/ledger-manifest.d.ts.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/__test__/config-files.navFiles.test.d.ts +2 -0
- package/dist/types/orpc-client/docs-ledger/__test__/config-files.navFiles.test.d.ts.map +1 -0
- package/dist/types/orpc-client/docs-ledger/config-files.d.ts +8 -0
- package/dist/types/orpc-client/docs-ledger/config-files.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/contract.d.ts +433 -28
- package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts +92 -0
- package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -60,6 +60,41 @@ function metaStr(metadata, key) {
|
|
|
60
60
|
}
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* V1 availability values stored in ledger metadata are lowercase (e.g. "deprecated"),
|
|
65
|
+
* but the latest Availability type uses PascalCase (e.g. "Deprecated"). This map
|
|
66
|
+
* normalises both formats so the badge component can look up display names correctly.
|
|
67
|
+
*/
|
|
68
|
+
const AVAILABILITY_LOOKUP = {
|
|
69
|
+
// V1 lowercase values (stored by docsPublishTransform from V1 navigation tree)
|
|
70
|
+
alpha: FernNavigation.Availability.Alpha,
|
|
71
|
+
stable: FernNavigation.Availability.Stable,
|
|
72
|
+
"generally-available": FernNavigation.Availability.GenerallyAvailable,
|
|
73
|
+
"in-development": FernNavigation.Availability.InDevelopment,
|
|
74
|
+
"pre-release": FernNavigation.Availability.PreRelease,
|
|
75
|
+
deprecated: FernNavigation.Availability.Deprecated,
|
|
76
|
+
beta: FernNavigation.Availability.Beta,
|
|
77
|
+
preview: FernNavigation.Availability.Preview,
|
|
78
|
+
legacy: FernNavigation.Availability.Legacy,
|
|
79
|
+
// Latest PascalCase values (pass-through)
|
|
80
|
+
Alpha: FernNavigation.Availability.Alpha,
|
|
81
|
+
Stable: FernNavigation.Availability.Stable,
|
|
82
|
+
GenerallyAvailable: FernNavigation.Availability.GenerallyAvailable,
|
|
83
|
+
InDevelopment: FernNavigation.Availability.InDevelopment,
|
|
84
|
+
PreRelease: FernNavigation.Availability.PreRelease,
|
|
85
|
+
Deprecated: FernNavigation.Availability.Deprecated,
|
|
86
|
+
Beta: FernNavigation.Availability.Beta,
|
|
87
|
+
Preview: FernNavigation.Availability.Preview,
|
|
88
|
+
Legacy: FernNavigation.Availability.Legacy
|
|
89
|
+
};
|
|
90
|
+
/** Read an availability field from metadata, converting V1 lowercase to latest PascalCase. */
|
|
91
|
+
function metaAvailability(metadata) {
|
|
92
|
+
const raw = metaStr(metadata, "availability");
|
|
93
|
+
if (raw == null) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return AVAILABILITY_LOOKUP[raw];
|
|
97
|
+
}
|
|
63
98
|
function metaBool(metadata, key) {
|
|
64
99
|
if (metadata != null && typeof metadata === "object" && key in metadata) {
|
|
65
100
|
const v = metadata[key];
|
|
@@ -198,7 +233,7 @@ function artifactToNode(ctx, route) {
|
|
|
198
233
|
}),
|
|
199
234
|
pageId: FernNavigation.PageId(pageId),
|
|
200
235
|
noindex: metaBool(md, "noindex"),
|
|
201
|
-
availability:
|
|
236
|
+
availability: metaAvailability(md)
|
|
202
237
|
};
|
|
203
238
|
return node;
|
|
204
239
|
}
|
|
@@ -269,7 +304,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
269
304
|
endpointId: FernNavigation.EndpointId(endpointId),
|
|
270
305
|
apiDefinitionId,
|
|
271
306
|
isResponseStream: metaBool(md, "isResponseStream"),
|
|
272
|
-
availability:
|
|
307
|
+
availability: metaAvailability(md),
|
|
273
308
|
playground: undefined
|
|
274
309
|
};
|
|
275
310
|
}
|
|
@@ -285,7 +320,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
285
320
|
method: method,
|
|
286
321
|
webhookId: FernNavigation.WebhookId(webhookId),
|
|
287
322
|
apiDefinitionId,
|
|
288
|
-
availability:
|
|
323
|
+
availability: metaAvailability(md)
|
|
289
324
|
};
|
|
290
325
|
}
|
|
291
326
|
if (route.type === "asyncapi") {
|
|
@@ -298,7 +333,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
298
333
|
...meta,
|
|
299
334
|
webSocketId: FernNavigation.WebSocketId(webSocketId),
|
|
300
335
|
apiDefinitionId,
|
|
301
|
-
availability:
|
|
336
|
+
availability: metaAvailability(md),
|
|
302
337
|
playground: undefined
|
|
303
338
|
};
|
|
304
339
|
}
|
|
@@ -314,7 +349,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
314
349
|
method: method,
|
|
315
350
|
grpcId: FernNavigation.GrpcId(grpcId),
|
|
316
351
|
apiDefinitionId,
|
|
317
|
-
availability:
|
|
352
|
+
availability: metaAvailability(md)
|
|
318
353
|
};
|
|
319
354
|
}
|
|
320
355
|
if (route.type === "graphql") {
|
|
@@ -330,7 +365,7 @@ function apiLeafNodeFromNavRouteInternal(ctx, route, segmentApiDefinitionId) {
|
|
|
330
365
|
graphqlOperationId: FernNavigation.GraphQlOperationId(graphqlOperationId),
|
|
331
366
|
graphqlOperationIds: undefined,
|
|
332
367
|
apiDefinitionId,
|
|
333
|
-
availability:
|
|
368
|
+
availability: metaAvailability(md),
|
|
334
369
|
playground: undefined
|
|
335
370
|
};
|
|
336
371
|
}
|
|
@@ -534,6 +569,30 @@ function stripLeadingScopePrefix(section, scopePrefix) {
|
|
|
534
569
|
}
|
|
535
570
|
return section;
|
|
536
571
|
}
|
|
572
|
+
function computeDuplicateSiblingSortBoundaries(siblings) {
|
|
573
|
+
const result = new Map();
|
|
574
|
+
const byPath = new Map();
|
|
575
|
+
for (const sibling of siblings) {
|
|
576
|
+
if (metaStr(sibling.seg.metadata, "type") !== "section") {
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
const group = byPath.get(sibling.seg.section) ?? [];
|
|
580
|
+
group.push(sibling);
|
|
581
|
+
byPath.set(sibling.seg.section, group);
|
|
582
|
+
}
|
|
583
|
+
for (const [, group] of byPath) {
|
|
584
|
+
if (group.length <= 1) {
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
for (let i = 0; i < group.length; i++) {
|
|
588
|
+
result.set(group[i], {
|
|
589
|
+
lo: group[i].seg.sortOrder,
|
|
590
|
+
hi: i + 1 < group.length ? group[i + 1].seg.sortOrder : Number.MAX_SAFE_INTEGER
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return result;
|
|
595
|
+
}
|
|
537
596
|
/**
|
|
538
597
|
* Merge leaf children and section children by their original V1 tree position.
|
|
539
598
|
* Leaves carry position via `displaySortOrder` (stored in nav routes), sections
|
|
@@ -597,7 +656,7 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
597
656
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
598
657
|
collapsible: metaBool(seg.metadata, "collapsible") ?? (metaCollapsed(seg.metadata) === true ? true : undefined),
|
|
599
658
|
collapsedByDefault: metaBool(seg.metadata, "collapsedByDefault") ?? (metaCollapsed(seg.metadata) === true ? true : undefined),
|
|
600
|
-
availability:
|
|
659
|
+
availability: metaAvailability(seg.metadata),
|
|
601
660
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : undefined,
|
|
602
661
|
children: mergeChildrenByPosition(ctx, nav, sectionChildren)
|
|
603
662
|
};
|
|
@@ -607,13 +666,16 @@ function sectionNode(ctx, scoped, sectionChildren, scopePrefix) {
|
|
|
607
666
|
* `parentSectionPath(seg.section) === parentSection`, or is an orphaned segment
|
|
608
667
|
* whose nearest existing ancestor is `parentSection`.
|
|
609
668
|
*/
|
|
610
|
-
function directChildApiPackages(parentSection, scopeSegs) {
|
|
669
|
+
function directChildApiPackages(parentSection, scopeSegs, apiDefinitionId) {
|
|
611
670
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
612
671
|
return scopeSegs
|
|
613
672
|
.filter((s) => {
|
|
614
673
|
if (metaStr(s.seg.metadata, "type") !== "apiPackage") {
|
|
615
674
|
return false;
|
|
616
675
|
}
|
|
676
|
+
if (metaStr(s.seg.metadata, "apiDefinitionId") !== apiDefinitionId) {
|
|
677
|
+
return false;
|
|
678
|
+
}
|
|
617
679
|
const parent = parentSectionPath(s.seg.section);
|
|
618
680
|
if (parent === parentSection) {
|
|
619
681
|
return true;
|
|
@@ -638,11 +700,37 @@ function buildApiChildren(ctx, scoped, scopeSegs, apiDefinitionId, scopePrefix)
|
|
|
638
700
|
// API leaf types.
|
|
639
701
|
const leafNodes = positionedApiLeafChildren(ctx, nav, apiDefinitionId);
|
|
640
702
|
// Build nested ApiPackageNodes from direct child apiPackage segments.
|
|
641
|
-
|
|
703
|
+
let childPackages = directChildApiPackages(seg.section, scopeSegs, apiDefinitionId);
|
|
704
|
+
// When multiple API-type segments share the same section path (skipUrlSlug
|
|
705
|
+
// group packages that collapse to their parent's section), children from
|
|
706
|
+
// different groups get mixed together. Scope children to this segment's DFS
|
|
707
|
+
// subtree using sortOrder boundaries to restore correct ownership.
|
|
708
|
+
const samePathApiSiblings = scopeSegs.filter((s) => s.seg.section === seg.section &&
|
|
709
|
+
s.seg.sortOrder !== seg.sortOrder &&
|
|
710
|
+
API_NODE_SEGMENT_TYPES.has(metaStr(s.seg.metadata, "type") ?? ""));
|
|
711
|
+
const hasCollapsedGroups = samePathApiSiblings.length > 0;
|
|
712
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") !== "apiReference") {
|
|
713
|
+
// This is a group package sharing its section with siblings.
|
|
714
|
+
// Only claim children whose sortOrder falls within our DFS subtree.
|
|
715
|
+
const nextSibling = samePathApiSiblings
|
|
716
|
+
.filter((s) => s.seg.sortOrder > seg.sortOrder)
|
|
717
|
+
.sort((a, b) => a.seg.sortOrder - b.seg.sortOrder)[0];
|
|
718
|
+
const lo = seg.sortOrder;
|
|
719
|
+
const hi = nextSibling?.seg.sortOrder ?? Number.MAX_SAFE_INTEGER;
|
|
720
|
+
childPackages = childPackages.filter((c) => c.seg.sortOrder > lo && c.seg.sortOrder < hi);
|
|
721
|
+
}
|
|
642
722
|
const packageNodes = childPackages.map((child) => ({
|
|
643
723
|
node: apiPackageChildNode(ctx, child, scopeSegs, apiDefinitionId, scopePrefix),
|
|
644
724
|
childIndex: metaNum(child.seg.metadata, "childIndex")
|
|
645
725
|
}));
|
|
726
|
+
// When collapsed groups are detected at apiReference level, children's
|
|
727
|
+
// childIndex values are relative to different parent groups and cannot be
|
|
728
|
+
// used for interleaving. Fall back to sortOrder (DFS creation order).
|
|
729
|
+
if (hasCollapsedGroups && metaStr(seg.metadata, "type") === "apiReference") {
|
|
730
|
+
return [...leafNodes, ...packageNodes.map((p, i) => ({ node: p.node, pos: leafNodes.length + i }))]
|
|
731
|
+
.sort((a, b) => a.pos - b.pos)
|
|
732
|
+
.map((p) => p.node);
|
|
733
|
+
}
|
|
646
734
|
// Interleave by position when childIndex metadata is available
|
|
647
735
|
const hasChildIndex = packageNodes.some((p) => p.childIndex != null);
|
|
648
736
|
if (!hasChildIndex) {
|
|
@@ -686,7 +774,7 @@ function apiPackageChildNode(ctx, scoped, scopeSegs, parentApiDefinitionId, scop
|
|
|
686
774
|
featureFlags: metaFeatureFlags(seg.metadata)
|
|
687
775
|
}),
|
|
688
776
|
apiDefinitionId: FernNavigation.ApiDefinitionId(apiDefinitionId),
|
|
689
|
-
availability:
|
|
777
|
+
availability: metaAvailability(seg.metadata),
|
|
690
778
|
overviewPageId: overviewPageId != null ? FernNavigation.PageId(overviewPageId) : undefined,
|
|
691
779
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
692
780
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : undefined,
|
|
@@ -796,10 +884,10 @@ function apiReferenceNode(ctx, scoped, scopeSegs, scopePrefix) {
|
|
|
796
884
|
featureFlags: metaFeatureFlags(seg.metadata)
|
|
797
885
|
}),
|
|
798
886
|
apiDefinitionId: FernNavigation.ApiDefinitionId(apiDefinitionId),
|
|
799
|
-
availability:
|
|
887
|
+
availability: metaAvailability(seg.metadata),
|
|
800
888
|
overviewPageId: overviewPageId != null ? FernNavigation.PageId(overviewPageId) : undefined,
|
|
801
889
|
noindex: metaBool(overview?.metadata, "noindex") ?? metaBool(seg.metadata, "noindex"),
|
|
802
|
-
paginated:
|
|
890
|
+
paginated: metaBool(seg.metadata, "paginated"),
|
|
803
891
|
showErrors: metaBool(seg.metadata, "showErrors"),
|
|
804
892
|
hideTitle: metaBool(seg.metadata, "hideTitle"),
|
|
805
893
|
pointsTo: metaPointsTo != null ? pointsToSlug(metaPointsTo) : undefined,
|
|
@@ -817,7 +905,12 @@ function attachedApiChangelogNode(ctx, scoped, scopeSegs, apiDefinitionId, scope
|
|
|
817
905
|
}
|
|
818
906
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
819
907
|
});
|
|
820
|
-
const
|
|
908
|
+
const apiReferenceCount = scopeSegs.filter((candidate) => {
|
|
909
|
+
return (metaStr(candidate.seg.metadata, "type") === "apiReference" &&
|
|
910
|
+
metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId);
|
|
911
|
+
}).length;
|
|
912
|
+
const changelogSeg = candidates.find((candidate) => parentSectionPath(candidate.seg.section) === seg.section) ??
|
|
913
|
+
(apiReferenceCount === 1 ? candidates[0] : undefined);
|
|
821
914
|
return changelogSeg != null ? changelogNode(ctx, changelogSeg, scopePrefix) : undefined;
|
|
822
915
|
}
|
|
823
916
|
function hasOwningApiReference(scoped, scopeSegs) {
|
|
@@ -825,12 +918,14 @@ function hasOwningApiReference(scoped, scopeSegs) {
|
|
|
825
918
|
if (apiDefinitionId == null || metaStr(scoped.seg.metadata, "type") !== "changelog") {
|
|
826
919
|
return false;
|
|
827
920
|
}
|
|
828
|
-
|
|
921
|
+
const candidates = scopeSegs.filter((candidate) => {
|
|
829
922
|
if (metaStr(candidate.seg.metadata, "type") !== "apiReference") {
|
|
830
923
|
return false;
|
|
831
924
|
}
|
|
832
925
|
return metaStr(candidate.seg.metadata, "apiDefinitionId") === apiDefinitionId;
|
|
833
926
|
});
|
|
927
|
+
return (candidates.some((candidate) => parentSectionPath(scoped.seg.section) === candidate.seg.section) ||
|
|
928
|
+
candidates.length === 1);
|
|
834
929
|
}
|
|
835
930
|
/**
|
|
836
931
|
* True when this segment is an `apiPackage` that will be nested under an in-scope
|
|
@@ -1001,6 +1096,20 @@ function nearestExistingAncestor(sectionPath, existing) {
|
|
|
1001
1096
|
*/
|
|
1002
1097
|
function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScopePrefix) {
|
|
1003
1098
|
const sectionPaths = new Set(scopeSegs.map((s) => s.seg.section));
|
|
1099
|
+
// Look up the parent segment's sidebarDepth so we can prevent false
|
|
1100
|
+
// adoption of siblings whose slug-derived path happens to create a
|
|
1101
|
+
// parent-child hierarchy (e.g. "sdks" and "sdks/checkout" at depth 1).
|
|
1102
|
+
// When multiple segments share parentPath, prefer the shallowest (depth-0)
|
|
1103
|
+
// as the authoritative parent — deeper ones are skipUrlSlug children.
|
|
1104
|
+
const parentCandidates = scopeSegs.filter((s) => s.seg.section === parentPath);
|
|
1105
|
+
const parentSeg = parentCandidates.length > 1
|
|
1106
|
+
? parentCandidates.reduce((best, cur) => {
|
|
1107
|
+
const bd = metaNum(best.seg.metadata, "sidebarDepth") ?? Number.MAX_SAFE_INTEGER;
|
|
1108
|
+
const cd = metaNum(cur.seg.metadata, "sidebarDepth") ?? Number.MAX_SAFE_INTEGER;
|
|
1109
|
+
return cd < bd ? cur : best;
|
|
1110
|
+
})
|
|
1111
|
+
: parentCandidates[0];
|
|
1112
|
+
const parentDepth = parentSeg != null ? metaNum(parentSeg.seg.metadata, "sidebarDepth") : undefined;
|
|
1004
1113
|
const direct = scopeSegs
|
|
1005
1114
|
.filter((s) => {
|
|
1006
1115
|
const sec = s.seg.section;
|
|
@@ -1011,6 +1120,27 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1011
1120
|
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1012
1121
|
return false;
|
|
1013
1122
|
}
|
|
1123
|
+
// Segments marked as sidebar depth 0 are V1 root-level peers and
|
|
1124
|
+
// must never be adopted as children of another section.
|
|
1125
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1126
|
+
if (depth === 0) {
|
|
1127
|
+
return false;
|
|
1128
|
+
}
|
|
1129
|
+
// SkipUrlSlug children: a segment sharing the parent's exact
|
|
1130
|
+
// section path at a deeper level is a child (e.g. Server-side SDKs
|
|
1131
|
+
// with sec="sdks" depth=1 under Integration options sec="sdks"
|
|
1132
|
+
// depth=0). Exclude the parent segment itself.
|
|
1133
|
+
if (sec === parentPath && s !== parentSeg && depth != null && parentDepth != null && depth > parentDepth) {
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1136
|
+
// Segments at the same (or shallower) depth as the parent are
|
|
1137
|
+
// siblings, not children. This prevents false nesting when a
|
|
1138
|
+
// skipUrlSlug parent produces multi-segment section paths that
|
|
1139
|
+
// look hierarchical (e.g. sections "sdks" and "sdks/checkout"
|
|
1140
|
+
// both at depth 1 are siblings, not parent-child).
|
|
1141
|
+
if (parentDepth != null && depth != null && depth <= parentDepth) {
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1014
1144
|
const parent = parentSectionPath(sec);
|
|
1015
1145
|
if (parent === parentPath) {
|
|
1016
1146
|
return true;
|
|
@@ -1023,6 +1153,7 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1023
1153
|
return false;
|
|
1024
1154
|
})
|
|
1025
1155
|
.sort((a, b) => a.seg.sortOrder - b.seg.sortOrder);
|
|
1156
|
+
const siblingBoundaries = computeDuplicateSiblingSortBoundaries(direct);
|
|
1026
1157
|
return direct.map((s) => {
|
|
1027
1158
|
const type = metaStr(s.seg.metadata, "type");
|
|
1028
1159
|
const childIndex = metaNum(s.seg.metadata, "childIndex");
|
|
@@ -1035,7 +1166,22 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1035
1166
|
}
|
|
1036
1167
|
else {
|
|
1037
1168
|
// section (or unrecognised) → recurse for nested sections.
|
|
1038
|
-
|
|
1169
|
+
// SkipUrlSlug children share the parent's section path, so
|
|
1170
|
+
// recursing with that path would re-find the same children
|
|
1171
|
+
// (infinite loop). Their subsections can't be distinguished by
|
|
1172
|
+
// path alone, so they get no recursive children — content comes
|
|
1173
|
+
// only from their leaf pages.
|
|
1174
|
+
const isSkipSlugChild = s.seg.section === parentPath;
|
|
1175
|
+
if (isSkipSlugChild) {
|
|
1176
|
+
node = sectionNode(ctx, s, [], scopePrefix);
|
|
1177
|
+
}
|
|
1178
|
+
else {
|
|
1179
|
+
const boundary = siblingBoundaries.get(s);
|
|
1180
|
+
const childScopeSegs = boundary != null
|
|
1181
|
+
? scopeSegs.filter((candidate) => candidate.seg.sortOrder >= boundary.lo && candidate.seg.sortOrder < boundary.hi)
|
|
1182
|
+
: scopeSegs;
|
|
1183
|
+
node = sectionNode(ctx, s, buildSectionTree(ctx, childScopeSegs, s.seg.section, scopePrefix, changelogScopePrefix), scopePrefix);
|
|
1184
|
+
}
|
|
1039
1185
|
}
|
|
1040
1186
|
return { node, childIndex };
|
|
1041
1187
|
});
|
|
@@ -1055,23 +1201,49 @@ function buildSectionTree(ctx, scopeSegs, parentPath, scopePrefix, changelogScop
|
|
|
1055
1201
|
function computeSiblingSortBoundaries(ordered) {
|
|
1056
1202
|
const result = new Map();
|
|
1057
1203
|
// Collect root-level sections grouped by their section path.
|
|
1204
|
+
// Sections with sec==="" (skip-slug sections) are included: when multiple
|
|
1205
|
+
// skip-slug sections exist at the root, they share path "" and need
|
|
1206
|
+
// boundaries so each only adopts its own children.
|
|
1058
1207
|
const sectionPaths = new Set(ordered.map((s) => s.seg.section));
|
|
1059
1208
|
const rootSections = [];
|
|
1060
1209
|
for (const s of ordered) {
|
|
1061
1210
|
const type = metaStr(s.seg.metadata, "type");
|
|
1062
1211
|
const sec = s.seg.section;
|
|
1063
|
-
if (type !== "section"
|
|
1212
|
+
if (type !== "section") {
|
|
1213
|
+
continue;
|
|
1214
|
+
}
|
|
1215
|
+
if (sec === "") {
|
|
1216
|
+
rootSections.push(s);
|
|
1064
1217
|
continue;
|
|
1065
1218
|
}
|
|
1219
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1066
1220
|
const parent = parentSectionPath(sec);
|
|
1067
|
-
const isRootLevel =
|
|
1221
|
+
const isRootLevel = depth === 0 ||
|
|
1222
|
+
parent === "" ||
|
|
1223
|
+
(!sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "");
|
|
1068
1224
|
if (isRootLevel) {
|
|
1069
1225
|
rootSections.push(s);
|
|
1070
1226
|
}
|
|
1071
1227
|
}
|
|
1228
|
+
// When a depth-0 section shares its path with a depth>0 section, the
|
|
1229
|
+
// deeper one is a skipUrlSlug child — not a true root-level sibling.
|
|
1230
|
+
// Remove it from the siblings list so boundaries aren't computed between
|
|
1231
|
+
// parent and child (which would give the parent a tiny ownership range).
|
|
1232
|
+
const depth0Paths = new Set();
|
|
1233
|
+
for (const s of rootSections) {
|
|
1234
|
+
if (metaNum(s.seg.metadata, "sidebarDepth") === 0) {
|
|
1235
|
+
depth0Paths.add(s.seg.section);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
const effectiveRootSections = rootSections.filter((s) => {
|
|
1239
|
+
const d = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1240
|
+
// Keep: depth-0 sections, sections without depth metadata, and
|
|
1241
|
+
// sections whose path has no depth-0 owner.
|
|
1242
|
+
return d === 0 || d == null || !depth0Paths.has(s.seg.section);
|
|
1243
|
+
});
|
|
1072
1244
|
// Group by section path — only paths with >1 section need boundaries.
|
|
1073
1245
|
const byPath = new Map();
|
|
1074
|
-
for (const s of
|
|
1246
|
+
for (const s of effectiveRootSections) {
|
|
1075
1247
|
const group = byPath.get(s.seg.section) ?? [];
|
|
1076
1248
|
group.push(s);
|
|
1077
1249
|
byPath.set(s.seg.section, group);
|
|
@@ -1109,6 +1281,17 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1109
1281
|
// segments. Both index into the SAME child list at write time, so they
|
|
1110
1282
|
// interleave directly (e.g. [page 0, page 1, section 2…15, page 16, 17]).
|
|
1111
1283
|
const annotated = [];
|
|
1284
|
+
// ── Sibling section ownership ────────────────────────────────────────
|
|
1285
|
+
//
|
|
1286
|
+
// Multiple root-level sections can share the same section path (e.g.
|
|
1287
|
+
// three sections all with path equal to the version slug). When this
|
|
1288
|
+
// happens, buildSectionTree would incorrectly give ALL child subsections
|
|
1289
|
+
// to each sibling. We resolve ownership via sortOrder: a section owns
|
|
1290
|
+
// segments whose sortOrder falls between its own and the next sibling's.
|
|
1291
|
+
//
|
|
1292
|
+
// Computed first because hasRootSection (below) uses it to decide
|
|
1293
|
+
// whether bounded skip-slug siblings should activate adoption.
|
|
1294
|
+
const siblingBoundaries = computeSiblingSortBoundaries(ordered);
|
|
1112
1295
|
// ── Root-section adoption flow ──────────────────────────────────────
|
|
1113
1296
|
//
|
|
1114
1297
|
// A scope may contain a "root section" — a segment with type "section"
|
|
@@ -1120,28 +1303,50 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1120
1303
|
// │ → emit pages/links inline at their displaySortOrder
|
|
1121
1304
|
// │
|
|
1122
1305
|
// ├─ (B) the root section itself (sec=="", type=="section")
|
|
1123
|
-
// │ → buildSectionTree adopts
|
|
1124
|
-
// │ → emit one sectionNode wrapping the
|
|
1306
|
+
// │ → buildSectionTree adopts nested children (depth > 0)
|
|
1307
|
+
// │ → emit one sectionNode wrapping the subtree
|
|
1125
1308
|
// │
|
|
1126
|
-
// └─ (C) depth-0 sections (parentSectionPath=="")
|
|
1127
|
-
// →
|
|
1309
|
+
// └─ (C) depth-0 sections (sidebarDepth==0 or parentSectionPath=="")
|
|
1310
|
+
// → emit directly as root children (not adopted by B)
|
|
1128
1311
|
//
|
|
1129
1312
|
// Without a root section, depth-0 sections are emitted directly.
|
|
1130
|
-
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" && s.seg.section === "");
|
|
1131
|
-
// ── Sibling section ownership ────────────────────────────────────────
|
|
1132
1313
|
//
|
|
1133
|
-
//
|
|
1134
|
-
//
|
|
1135
|
-
//
|
|
1136
|
-
//
|
|
1137
|
-
//
|
|
1138
|
-
|
|
1314
|
+
// A section with sec=="" AND `childIndex` in its metadata is a sibling
|
|
1315
|
+
// inside a V1 sidebarGroup that has skipUrlSlug — not a true structural
|
|
1316
|
+
// wrapper. `walkNavSubTrees` always passes `childIndex`; direct
|
|
1317
|
+
// sidebarRoot children (true wrappers) never receive one.
|
|
1318
|
+
//
|
|
1319
|
+
// Such siblings only activate adoption when they have sortOrder
|
|
1320
|
+
// boundaries (multiple sec="" sections sharing the same path), which
|
|
1321
|
+
// correctly scope each section's children. A *single* unbounded
|
|
1322
|
+
// skip-slug sibling (e.g. mangopay's "Introduction") must NOT adopt
|
|
1323
|
+
// its depth-0 peers — doing so produces spurious breadcrumb entries.
|
|
1324
|
+
const hasRootSection = ordered.some((s) => metaStr(s.seg.metadata, "type") === "section" &&
|
|
1325
|
+
s.seg.section === "" &&
|
|
1326
|
+
(metaNum(s.seg.metadata, "childIndex") == null || siblingBoundaries.has(s)));
|
|
1327
|
+
// Paths that have a depth-0 section — deeper sections sharing that path
|
|
1328
|
+
// are skipUrlSlug children adopted by the depth-0 section, not root peers.
|
|
1329
|
+
const depth0SectionPaths = new Set();
|
|
1330
|
+
for (const s of ordered) {
|
|
1331
|
+
if (metaStr(s.seg.metadata, "type") === "section" && metaNum(s.seg.metadata, "sidebarDepth") === 0) {
|
|
1332
|
+
depth0SectionPaths.add(s.seg.section);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1139
1335
|
for (const s of ordered) {
|
|
1140
1336
|
const type = metaStr(s.seg.metadata, "type");
|
|
1141
1337
|
const sec = s.seg.section;
|
|
1142
1338
|
if (hasOwningApiReference(s, scopeSegs) || isNestedApiPackage(s, scopeSegs)) {
|
|
1143
1339
|
continue;
|
|
1144
1340
|
}
|
|
1341
|
+
// Skip apiPackage segments that share their section path with an
|
|
1342
|
+
// apiReference sibling (skipUrlSlug structural wrappers). Their
|
|
1343
|
+
// children are already claimed by the apiReference via DFS ordering.
|
|
1344
|
+
if (type === "apiPackage") {
|
|
1345
|
+
const hasApiRefSibling = ordered.some((sib) => sib.seg.section === sec && metaStr(sib.seg.metadata, "type") === "apiReference");
|
|
1346
|
+
if (hasApiRefSibling) {
|
|
1347
|
+
continue;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1145
1350
|
if (type === "tabRoot" && metaBool(s.seg.metadata, "landingPage") === true) {
|
|
1146
1351
|
continue;
|
|
1147
1352
|
}
|
|
@@ -1158,21 +1363,41 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1158
1363
|
continue;
|
|
1159
1364
|
}
|
|
1160
1365
|
// (B) Root section wrapper — adopts depth-0 children via buildSectionTree.
|
|
1161
|
-
|
|
1162
|
-
|
|
1366
|
+
// Only applies to true root wrappers (no childIndex); sibling
|
|
1367
|
+
// sections with skipUrlSlug (have childIndex) fall through to (C).
|
|
1368
|
+
// When multiple sections share sec==="" (skip-slug), scope children
|
|
1369
|
+
// to each section's sortOrder range so subsections aren't duplicated.
|
|
1370
|
+
if (type === "section" && sec === "" && hasRootSection) {
|
|
1371
|
+
const bounds = siblingBoundaries.get(s);
|
|
1372
|
+
const ownedSegs = bounds != null
|
|
1373
|
+
? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi)
|
|
1374
|
+
: scopeSegs;
|
|
1375
|
+
const sectionChildren = buildSectionTree(ctx, ownedSegs, "", scopePrefix, changelogScopePrefix);
|
|
1163
1376
|
const node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1164
1377
|
annotated.push({ node, pos: metaNum(s.seg.metadata, "childIndex"), isLeaf: false });
|
|
1165
1378
|
continue;
|
|
1166
1379
|
}
|
|
1167
1380
|
// (C) Depth-0 or orphaned sections — emit at root unless already
|
|
1168
1381
|
// adopted by a root section (B).
|
|
1382
|
+
const depth = metaNum(s.seg.metadata, "sidebarDepth");
|
|
1169
1383
|
const parent = parentSectionPath(sec);
|
|
1170
|
-
const isRootLevel =
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
//
|
|
1174
|
-
//
|
|
1175
|
-
|
|
1384
|
+
const isRootLevel = depth === 0 ||
|
|
1385
|
+
parent === "" ||
|
|
1386
|
+
(!sectionPaths.has(parent) && nearestExistingAncestor(sec, sectionPaths) === "");
|
|
1387
|
+
// Skip sections already adopted by the root section wrapper (B).
|
|
1388
|
+
// Sections with sidebarDepth===0 are true V1 root peers that
|
|
1389
|
+
// buildSectionTree now excludes — they must NOT be skipped.
|
|
1390
|
+
// Sections with sidebarDepth>0 are nested children that SHOULD
|
|
1391
|
+
// be adopted, so they must be skipped to avoid duplication.
|
|
1392
|
+
// Sections without sidebarDepth (old data) are also skipped —
|
|
1393
|
+
// they rely on path-based hierarchy in buildSectionTree.
|
|
1394
|
+
if (isRootLevel && hasRootSection && sec !== "" && depth !== 0) {
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
// Skip depth>0 sections that share their path with a depth-0
|
|
1398
|
+
// section — they are skipUrlSlug children adopted via
|
|
1399
|
+
// buildSectionTree by the depth-0 owner, not root peers.
|
|
1400
|
+
if (isRootLevel && depth != null && depth > 0 && depth0SectionPaths.has(sec)) {
|
|
1176
1401
|
continue;
|
|
1177
1402
|
}
|
|
1178
1403
|
if (isRootLevel) {
|
|
@@ -1190,7 +1415,26 @@ function buildSidebarRootChildren(ctx, scopeSegs, scopePrefix, changelogScopePre
|
|
|
1190
1415
|
const ownedSegs = bounds != null
|
|
1191
1416
|
? scopeSegs.filter((seg) => seg.seg.sortOrder >= bounds.lo && seg.seg.sortOrder < bounds.hi)
|
|
1192
1417
|
: scopeSegs;
|
|
1193
|
-
|
|
1418
|
+
// A section with sec="" that reaches here (not adopted as a
|
|
1419
|
+
// root wrapper in case B) is a skipUrlSlug sibling.
|
|
1420
|
+
// When sortOrder boundaries exist (multiple sec="" sections),
|
|
1421
|
+
// the scoped ownedSegs correctly limits which subsections
|
|
1422
|
+
// each section can adopt. When there are NO boundaries
|
|
1423
|
+
// (single sec="" section), buildSectionTree("") could
|
|
1424
|
+
// re-adopt depth-0 peers. However, when child segments
|
|
1425
|
+
// with sidebarDepth > 0 exist, buildSectionTree's
|
|
1426
|
+
// depth===0 filter already excludes peers — so adoption
|
|
1427
|
+
// is safe and necessary to preserve the parent hierarchy.
|
|
1428
|
+
const isUnboundedSkipSlugSibling = sec === "" && metaNum(s.seg.metadata, "childIndex") != null && bounds == null;
|
|
1429
|
+
const hasDepthMarkedChildren = isUnboundedSkipSlugSibling &&
|
|
1430
|
+
ownedSegs.some((candidate) => {
|
|
1431
|
+
const d = metaNum(candidate.seg.metadata, "sidebarDepth");
|
|
1432
|
+
return d != null && d > 0 && parentSectionPath(candidate.seg.section) === sec;
|
|
1433
|
+
});
|
|
1434
|
+
const sectionChildren = isUnboundedSkipSlugSibling && !hasDepthMarkedChildren
|
|
1435
|
+
? []
|
|
1436
|
+
: buildSectionTree(ctx, ownedSegs, sec, scopePrefix, changelogScopePrefix);
|
|
1437
|
+
node = sectionNode(ctx, s, sectionChildren, scopePrefix);
|
|
1194
1438
|
}
|
|
1195
1439
|
// Shared/merged sections (paths not rooted in scopePrefix) must not
|
|
1196
1440
|
// carry childIndex — their source-version positions would sort them
|
|
@@ -1260,11 +1504,6 @@ function groupSidebarRootChildren(ctx, children) {
|
|
|
1260
1504
|
flushRun();
|
|
1261
1505
|
out.push(child);
|
|
1262
1506
|
}
|
|
1263
|
-
else if (child.type === "changelog") {
|
|
1264
|
-
flushRun();
|
|
1265
|
-
run.push(child);
|
|
1266
|
-
flushRun();
|
|
1267
|
-
}
|
|
1268
1507
|
else {
|
|
1269
1508
|
run.push(child);
|
|
1270
1509
|
}
|
|
@@ -1431,7 +1670,7 @@ function buildVariantedNode(ctx, variants, scopeSegs, scopePrefix) {
|
|
|
1431
1670
|
? asSlug(FernNavigation.slugjoin(scopePrefix, variantIndividualSlug))
|
|
1432
1671
|
: scopePrefix;
|
|
1433
1672
|
const metaPointsTo = metaStr(variant.metadata, "pointsTo");
|
|
1434
|
-
const children = buildSidebarRootChildren(ctx, variantSegs,
|
|
1673
|
+
const children = buildSidebarRootChildren(ctx, variantSegs, variantSlug);
|
|
1435
1674
|
return {
|
|
1436
1675
|
type: "variant",
|
|
1437
1676
|
...withMetadataDefaults({
|
|
@@ -1967,6 +2206,14 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
1967
2206
|
};
|
|
1968
2207
|
return node;
|
|
1969
2208
|
});
|
|
2209
|
+
// Cross-product canonical slug deduplication (V2 parity).
|
|
2210
|
+
// V2's migrator deduplicates pages across products via a global pageId map:
|
|
2211
|
+
// the first product to register a pageId wins, and subsequent products'
|
|
2212
|
+
// pages with the same pageId receive a canonicalSlug pointing to the
|
|
2213
|
+
// canonical (default-product) page. Without this, shared content that is
|
|
2214
|
+
// materialized under every product scope (e.g. merge-api-basics pages)
|
|
2215
|
+
// appears as separate sitemap entries per product.
|
|
2216
|
+
markCrossProductCanonicalSlugs(children);
|
|
1970
2217
|
return {
|
|
1971
2218
|
type: "productgroup",
|
|
1972
2219
|
id: ctx.nodeId("productgroup"),
|
|
@@ -1975,5 +2222,43 @@ function buildProductGroup(ctx, products, scoped, rootSlug, skipSharedSectionMer
|
|
|
1975
2222
|
children
|
|
1976
2223
|
};
|
|
1977
2224
|
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Deduplicate pages across products using pageId as a content-identity key.
|
|
2227
|
+
* Pages with the same pageId in different products are the same content
|
|
2228
|
+
* materialized per-scope; the default product's slug becomes canonical and
|
|
2229
|
+
* non-default copies receive `canonicalSlug` so the sitemap collapses them.
|
|
2230
|
+
*
|
|
2231
|
+
* API leaf nodes (endpoints, websockets, etc.) are unaffected — `getPageId`
|
|
2232
|
+
* returns undefined for those types, so product-specific API surface is
|
|
2233
|
+
* never suppressed.
|
|
2234
|
+
*/
|
|
2235
|
+
function markCrossProductCanonicalSlugs(productNodes) {
|
|
2236
|
+
const pageIdToCanonical = new Map();
|
|
2237
|
+
// Process default product first so its slugs become the canonical targets.
|
|
2238
|
+
const sorted = [...productNodes].sort((a, b) => {
|
|
2239
|
+
if (a.default !== b.default) {
|
|
2240
|
+
return a.default ? -1 : 1;
|
|
2241
|
+
}
|
|
2242
|
+
return 0;
|
|
2243
|
+
});
|
|
2244
|
+
for (const product of sorted) {
|
|
2245
|
+
FernNavigation.traverseDF(product, (child) => {
|
|
2246
|
+
if (FernNavigation.hasMetadata(child) && FernNavigation.isPage(child)) {
|
|
2247
|
+
const pid = FernNavigation.getPageId(child);
|
|
2248
|
+
if (pid == null) {
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
const key = `pid:${pid}`;
|
|
2252
|
+
const canonical = pageIdToCanonical.get(key);
|
|
2253
|
+
if (canonical != null && !product.default) {
|
|
2254
|
+
child.canonicalSlug = canonical;
|
|
2255
|
+
}
|
|
2256
|
+
else if (canonical == null) {
|
|
2257
|
+
pageIdToCanonical.set(key, child.canonicalSlug ?? child.slug);
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
1978
2263
|
// (root keeps the bare "root" id; it is the single tree root.)
|
|
1979
2264
|
//# sourceMappingURL=ledger-root-builder.js.map
|