@salesforcedevs/docs-components 1.34.0-docs-feedback-1 → 1.34.0-docs-feedback-3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.34.0-docs-feedback-1",
3
+ "version": "1.34.0-docs-feedback-3",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -11,8 +11,10 @@ import type { OptionWithLink, TreeNode } from "typings/custom";
11
11
  const TOPIC_TYPE_SPEC = "spec";
12
12
 
13
13
  /**
14
- * Returns the parent's first direct child when it is a markdown content
15
- * page or undefined otherwise.
14
+ * Walks down the first-child chain and returns the first markdown content
15
+ * page found, descending through nested content-less parents. Returns
16
+ * undefined if the chain breaks on a spec or external link before reaching a
17
+ * content page.
16
18
  */
17
19
  function firstChildContentPage(node: TreeNode): TreeNode | undefined {
18
20
  const firstChild = node.children?.[0];
@@ -23,11 +25,15 @@ function firstChildContentPage(node: TreeNode): TreeNode | undefined {
23
25
  const isSpec =
24
26
  (firstChild as { topicType?: string }).topicType === TOPIC_TYPE_SPEC;
25
27
  const isExternal = firstChild.link?.target === "_blank";
26
- if (isSpec || isExternal || !firstChild.link?.href) {
28
+ if (isSpec || isExternal) {
27
29
  return undefined;
28
30
  }
29
31
 
30
- return firstChild;
32
+ if (firstChild.link?.href) {
33
+ return firstChild;
34
+ }
35
+
36
+ return firstChildContentPage(firstChild);
31
37
  }
32
38
 
33
39
  /**
@@ -54,10 +60,10 @@ function decorateTopics(
54
60
  !!decorated.children?.length && !decorated.link?.href;
55
61
 
56
62
  if (isContentlessParent) {
63
+ decorated.redirectToChild = true;
57
64
  const firstChild = firstChildContentPage(topic);
58
65
  if (firstChild?.link) {
59
66
  decorated.link = { ...firstChild.link };
60
- decorated.redirectToChild = true;
61
67
  }
62
68
  }
63
69