@fern-api/fdr-sdk 1.2.50-c32b5f74fd → 1.2.51-403b2eae4f

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.
@@ -2449,8 +2449,27 @@ function buildLandingPage(ctx, scopeSegs) {
2449
2449
  landingSegment?.nav.find((route) => route.type === "markdown")
2450
2450
  );
2451
2451
  }
2452
+ function buildSlugOwnerContentKeys(roots) {
2453
+ const slugOwnerKeys = /* @__PURE__ */ new Map();
2454
+ for (const root of roots) {
2455
+ traverseDF(root, (child, parents) => {
2456
+ if (hasMetadata(child) && isPage(child) && !slugOwnerKeys.has(child.slug)) {
2457
+ slugOwnerKeys.set(child.slug, new Set(crossVersionDedupKeys(child, parents)));
2458
+ }
2459
+ });
2460
+ }
2461
+ return slugOwnerKeys;
2462
+ }
2463
+ function canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys) {
2464
+ const ownerKeys = slugOwnerKeys.get(canonical);
2465
+ if (ownerKeys == null) {
2466
+ return false;
2467
+ }
2468
+ return keys.some((key) => key.startsWith("pid:") && ownerKeys.has(key));
2469
+ }
2452
2470
  function markWithinScopeCanonicalSlugs(scopeNode) {
2453
2471
  const keyToCanonical = /* @__PURE__ */ new Map();
2472
+ const slugOwnerKeys = buildSlugOwnerContentKeys([scopeNode]);
2454
2473
  traverseDF(scopeNode, (child, parents) => {
2455
2474
  if (hasMetadata(child) && isPage(child)) {
2456
2475
  const keys = crossVersionDedupKeys(child, parents);
@@ -2458,7 +2477,7 @@ function markWithinScopeCanonicalSlugs(scopeNode) {
2458
2477
  for (const key of keys) {
2459
2478
  const canonical = keyToCanonical.get(key);
2460
2479
  if (canonical != null && canonical !== child.slug) {
2461
- if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0) {
2480
+ if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0 && !canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys)) {
2462
2481
  continue;
2463
2482
  }
2464
2483
  child.canonicalSlug = canonical;
@@ -2485,6 +2504,7 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2485
2504
  }
2486
2505
  return 0;
2487
2506
  });
2507
+ const slugOwnerKeys = buildSlugOwnerContentKeys(sorted);
2488
2508
  for (const version of sorted) {
2489
2509
  traverseDF(version, (child, parents) => {
2490
2510
  if (hasMetadata(child) && isPage(child)) {
@@ -2493,7 +2513,7 @@ function markCrossVersionCanonicalSlugs(versionNodes) {
2493
2513
  for (const key of keys) {
2494
2514
  const canonical = keyToCanonical.get(key);
2495
2515
  if (canonical != null && !version.default) {
2496
- if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0) {
2516
+ if (child.slug.startsWith(canonical + "/") && getChildren(child).length > 0 && !canonicalOwnerSharesContent(slugOwnerKeys, canonical, keys)) {
2497
2517
  continue;
2498
2518
  }
2499
2519
  child.canonicalSlug = canonical;