@salesforcedevs/docs-components 1.34.3-final-alpha → 1.34.3-final-alpha1
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
|
@@ -16,36 +16,13 @@ import type { DocPhaseInfo, OptionWithLink, TreeNode } from "typings/custom";
|
|
|
16
16
|
*/
|
|
17
17
|
const TOPIC_TYPE_SPEC = "spec";
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Walks down the first-child chain and returns the first markdown content
|
|
21
|
-
* page found, descending through nested content-less parents. Returns
|
|
22
|
-
* undefined if the chain breaks on a spec or external link before reaching a
|
|
23
|
-
* content page.
|
|
24
|
-
*/
|
|
25
|
-
function firstChildContentPage(node: TreeNode): TreeNode | undefined {
|
|
26
|
-
const firstChild = node.children?.[0];
|
|
27
|
-
if (!firstChild) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const isSpec =
|
|
32
|
-
(firstChild as { topicType?: string }).topicType === TOPIC_TYPE_SPEC;
|
|
33
|
-
const isExternal = firstChild.link?.target === "_blank";
|
|
34
|
-
if (isSpec || isExternal) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (firstChild.link?.href) {
|
|
39
|
-
return firstChild;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return firstChildContentPage(firstChild);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
19
|
/**
|
|
46
20
|
* Translates per-topic `topicType` into the generic `showForwardArrow` flag
|
|
47
|
-
* that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc)
|
|
48
|
-
*
|
|
21
|
+
* that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc).
|
|
22
|
+
*
|
|
23
|
+
* Content-less parents are left without a link. The tree treats them as
|
|
24
|
+
* parent-only sections and selects the first markdown descendant. Copying that
|
|
25
|
+
* child's href onto the parent makes the parent win selection.
|
|
49
26
|
*/
|
|
50
27
|
function decorateTopicsWithForwardArrow(
|
|
51
28
|
topics:
|
|
@@ -67,20 +44,6 @@ function decorateTopicsWithForwardArrow(
|
|
|
67
44
|
);
|
|
68
45
|
}
|
|
69
46
|
|
|
70
|
-
/** Redirect a parent that has no content of its own to its first child
|
|
71
|
-
* but only when that first child is itself a content page
|
|
72
|
-
*/
|
|
73
|
-
const isContentlessParent =
|
|
74
|
-
!!decorated.children?.length && !decorated.link?.href;
|
|
75
|
-
|
|
76
|
-
if (isContentlessParent) {
|
|
77
|
-
decorated.redirectToChild = true;
|
|
78
|
-
const firstChild = firstChildContentPage(topic);
|
|
79
|
-
if (firstChild?.link) {
|
|
80
|
-
decorated.link = { ...firstChild.link };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
47
|
return decorated;
|
|
85
48
|
});
|
|
86
49
|
}
|