@salesforcedevs/dx-components 1.3.206-alpha.22 → 1.3.206-alpha.23
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
|
@@ -57,10 +57,10 @@ const resultsTemplatesInnerHtml = `
|
|
|
57
57
|
<% } %>
|
|
58
58
|
</div>
|
|
59
59
|
<p class="dx-result-title">
|
|
60
|
-
<
|
|
60
|
+
<span
|
|
61
61
|
class="CoveoResultLink"
|
|
62
|
-
data-field="@
|
|
63
|
-
></
|
|
62
|
+
data-field="@uri"
|
|
63
|
+
></span>
|
|
64
64
|
</p>
|
|
65
65
|
<p class="dx-result-excerpt CoveoExcerpt"></p>
|
|
66
66
|
</div>
|
|
@@ -91,6 +91,14 @@ const resultsTemplatesInnerHtml = `
|
|
|
91
91
|
</script>
|
|
92
92
|
`;
|
|
93
93
|
|
|
94
|
+
const isInternalDomain = (domain: string) =>
|
|
95
|
+
domain === "developer.salesforce.com" ||
|
|
96
|
+
domain === "developer-website-s.herokuapp.com";
|
|
97
|
+
|
|
98
|
+
const isTrailheadDomain = (domain: string) =>
|
|
99
|
+
domain === "trailhead.salesforce.com" ||
|
|
100
|
+
domain === "dev.trailhead.salesforce.com";
|
|
101
|
+
|
|
94
102
|
const buildTemplateHelperBadge = (value: keyof typeof CONTENT_TYPE_LABELS) => {
|
|
95
103
|
const style = getContentTypeColorVariables(value);
|
|
96
104
|
const label = CONTENT_TYPE_LABELS[value];
|
|
@@ -110,22 +118,31 @@ const buildTemplateHelperBadge = (value: keyof typeof CONTENT_TYPE_LABELS) => {
|
|
|
110
118
|
`;
|
|
111
119
|
};
|
|
112
120
|
|
|
113
|
-
const processParts = (parts: string[]) => {
|
|
114
|
-
return parts
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
const processParts = (parts: string[], internalFlag = false) => {
|
|
122
|
+
return parts
|
|
123
|
+
.filter((part) => {
|
|
124
|
+
// remove /docs/ as a breadcrumb item
|
|
125
|
+
if (internalFlag) {
|
|
126
|
+
return part !== "docs";
|
|
127
|
+
}
|
|
128
|
+
return part;
|
|
129
|
+
})
|
|
130
|
+
.map((part) => {
|
|
131
|
+
// Remove special characters & .htm/.xml extension
|
|
132
|
+
part = part
|
|
133
|
+
.replace(/_/g, " ")
|
|
134
|
+
.replace(/-/g, " ")
|
|
135
|
+
.replace(/.html*/g, " ")
|
|
136
|
+
.replace(/.xml/g, " ")
|
|
137
|
+
.replace(/b2c/g, "B2C");
|
|
138
|
+
|
|
139
|
+
// Capitalize first letter of each word
|
|
140
|
+
part = part.replace(/\w\S*/g, (w) => {
|
|
141
|
+
return w.replace(/^\w/, (c) => c.toUpperCase());
|
|
142
|
+
});
|
|
126
143
|
|
|
127
|
-
|
|
128
|
-
|
|
144
|
+
return `<span class="breadcrumb-item">${decodeURI(part)}</span>`;
|
|
145
|
+
});
|
|
129
146
|
};
|
|
130
147
|
|
|
131
148
|
const buildTemplateHelperUriBreadcrumbs = (value: string) => {
|
|
@@ -141,22 +158,16 @@ const buildTemplateHelperUriBreadcrumbs = (value: string) => {
|
|
|
141
158
|
let parts = url.pathname.split("/").filter((part) => part !== "");
|
|
142
159
|
|
|
143
160
|
// Remove language prefix from trailhead URLs
|
|
144
|
-
if (
|
|
145
|
-
url.hostname === "trailhead.salesforce.com" ||
|
|
146
|
-
url.hostname === "dev.trailhead.salesforce.com"
|
|
147
|
-
) {
|
|
161
|
+
if (isTrailheadDomain(url.hostname)) {
|
|
148
162
|
parts = parts
|
|
149
163
|
.slice(1)
|
|
150
164
|
.filter((part) => part !== "content" && part !== "learn");
|
|
151
165
|
}
|
|
152
166
|
|
|
153
|
-
const breadcrumbs = processParts(parts);
|
|
167
|
+
const breadcrumbs = processParts(parts, isInternalDomain(url.hostname));
|
|
154
168
|
|
|
155
169
|
// if url.hostname is developer.salesforce.com or developer-website-s.herokuapp.com, remove the first breadcrumb item
|
|
156
|
-
if (
|
|
157
|
-
url.hostname !== "developer.salesforce.com" &&
|
|
158
|
-
url.hostname !== "developer-website-s.herokuapp.com"
|
|
159
|
-
) {
|
|
170
|
+
if (!isInternalDomain(url.hostname)) {
|
|
160
171
|
breadcrumbs.unshift(
|
|
161
172
|
`<span class="breadcrumb-item">${url.hostname}</span>`
|
|
162
173
|
);
|