@salesforcedevs/docs-components 1.28.7-alpha.14 → 1.28.7-alpha.19

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/lwc.config.json CHANGED
@@ -6,6 +6,8 @@
6
6
  ],
7
7
  "expose": [
8
8
  "doc/amfReference",
9
+ "doc/banner",
10
+ "doc/localeBanner",
9
11
  "doc/breadcrumbs",
10
12
  "doc/componentPlayground",
11
13
  "doc/content",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.28.7-alpha.14",
3
+ "version": "1.28.7-alpha.19",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -25,5 +25,5 @@
25
25
  "@types/lodash.orderby": "4.6.9",
26
26
  "@types/lodash.uniqby": "4.7.9"
27
27
  },
28
- "gitHead": "01442763b9d41a4eb0f50911dba1bb1f5b94f5c8"
28
+ "gitHead": "7f1186e3e6c95f836b5fc9caf07d31291fa90fd5"
29
29
  }
@@ -0,0 +1,88 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+
4
+ :host {
5
+ display: block;
6
+
7
+ --doc-banner-padding-left: var(--dx-g-spacing-2xl);
8
+ --doc-banner-padding-right: var(--dx-g-spacing-lg);
9
+ }
10
+
11
+ .container {
12
+ display: flex;
13
+ align-items: flex-start;
14
+ background: var(--dx-g-gray-90);
15
+ padding: 0 var(--doc-banner-padding-right) 0 var(--doc-banner-padding-left);
16
+ }
17
+
18
+ .icon {
19
+ --dx-c-icon-size: var(--dx-g-icon-size-lg);
20
+
21
+ flex-shrink: 0;
22
+ margin-top: var(--dx-g-spacing-smd);
23
+ margin-right: var(--dx-g-spacing-sm);
24
+ }
25
+
26
+ .main {
27
+ flex: 1;
28
+ min-width: 0;
29
+ display: flex;
30
+ flex-wrap: wrap;
31
+ align-items: flex-start;
32
+ column-gap: var(--dx-g-spacing-md);
33
+ padding: calc((var(--dx-g-spacing-xs) + var(--dx-g-spacing-sm)) / 2) 0;
34
+ }
35
+
36
+ .message {
37
+ flex: 0 1 auto;
38
+ font-size: var(--dx-g-text-sm);
39
+ color: var(--dx-g-gray-10);
40
+ padding: calc((var(--dx-g-spacing-xs) + var(--dx-g-spacing-sm)) / 2) 0;
41
+ }
42
+
43
+ .message a {
44
+ color: var(--dx-g-cloud-blue-vibrant-50);
45
+ text-decoration: underline;
46
+ }
47
+
48
+ .actions {
49
+ flex: 0 0 auto;
50
+ display: flex;
51
+ align-items: center;
52
+ gap: var(--dx-g-spacing-smd);
53
+ }
54
+
55
+ .actions dx-button {
56
+ --dx-c-button-font-size: var(--dx-g-text-sm);
57
+ --dx-c-button-font-weight: var(--dx-g-font-normal);
58
+
59
+ flex: 0 0 auto;
60
+ }
61
+
62
+ .close {
63
+ --dx-c-icon-size: var(--dx-g-icon-size-lg);
64
+
65
+ flex-shrink: 0;
66
+ align-self: flex-start;
67
+ width: calc(var(--dx-g-spacing-3xl) + var(--dx-g-spacing-xs));
68
+ height: calc(var(--dx-g-spacing-2xl) + var(--dx-g-spacing-xs));
69
+ margin-left: auto;
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ cursor: pointer;
74
+ }
75
+
76
+ @media (max-width: 1279px) {
77
+ :host {
78
+ --doc-banner-padding-left: var(--dx-g-spacing-xl);
79
+ --doc-banner-padding-right: var(--dx-g-spacing-md);
80
+ }
81
+ }
82
+
83
+ @media (max-width: 768px) {
84
+ :host {
85
+ --doc-banner-padding-left: var(--dx-g-spacing-lg);
86
+ --doc-banner-padding-right: var(--dx-g-spacing-sm);
87
+ }
88
+ }
@@ -0,0 +1,47 @@
1
+ <template>
2
+ <template lwc:if={showBanner}>
3
+ <div class="container" part="container">
4
+ <dx-icon
5
+ class="icon"
6
+ symbol="info"
7
+ size="override"
8
+ color="gray-50"
9
+ part="icon"
10
+ ></dx-icon>
11
+ <div class="main">
12
+ <div class="message" part="message" lwc:dom="manual"></div>
13
+ <div class="actions" part="actions">
14
+ <template lwc:if={hasPrimaryButton}>
15
+ <dx-button
16
+ href={buttonHref}
17
+ variant="primary"
18
+ size="small"
19
+ part="button"
20
+ >
21
+ {buttonLabel}
22
+ </dx-button>
23
+ </template>
24
+ <template lwc:if={hasSecondaryAction}>
25
+ <dx-button
26
+ variant="inline"
27
+ onclick={handleSecondaryClick}
28
+ part="secondary"
29
+ >
30
+ {secondaryLabel}
31
+ </dx-button>
32
+ </template>
33
+ </div>
34
+ </div>
35
+ <dx-button
36
+ class="close"
37
+ variant="icon-only"
38
+ icon-symbol="close"
39
+ icon-size="override"
40
+ icon-color="gray-50"
41
+ aria-label="Close"
42
+ onclick={handleCloseClick}
43
+ part="close"
44
+ ></dx-button>
45
+ </div>
46
+ </template>
47
+ </template>
@@ -0,0 +1,73 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ const BANNER_STORAGE_PREFIX = "doc-banner-";
4
+
5
+ export default class Banner extends LightningElement {
6
+ @api message = "";
7
+
8
+ @api buttonLabel = "";
9
+
10
+ @api buttonHref = "";
11
+
12
+ @api secondaryLabel = "";
13
+
14
+ @api dismissStorageKey = "";
15
+
16
+ private _dismissed = false;
17
+
18
+ connectedCallback() {
19
+ if (this.dismissStorageKey && window?.sessionStorage) {
20
+ this._dismissed =
21
+ window.sessionStorage.getItem(
22
+ `${BANNER_STORAGE_PREFIX}${this.dismissStorageKey}`
23
+ ) === "true";
24
+ }
25
+ }
26
+
27
+ renderedCallback() {
28
+ if (this.message) {
29
+ const messageElement = this.template.querySelector(".message");
30
+ if (messageElement) {
31
+ messageElement.innerHTML = this.message;
32
+ }
33
+ }
34
+ }
35
+
36
+ get showBanner(): boolean {
37
+ return !this._dismissed;
38
+ }
39
+
40
+ get hasPrimaryButton(): boolean {
41
+ return !!(this.buttonLabel && this.buttonHref);
42
+ }
43
+
44
+ get hasSecondaryAction(): boolean {
45
+ return !!this.secondaryLabel;
46
+ }
47
+
48
+ private dismissBanner() {
49
+ if (this.dismissStorageKey && window?.sessionStorage) {
50
+ window.sessionStorage.setItem(
51
+ `${BANNER_STORAGE_PREFIX}${this.dismissStorageKey}`,
52
+ "true"
53
+ );
54
+ }
55
+ this._dismissed = true;
56
+ this.dispatchEvent(
57
+ new CustomEvent("dismissbanner", {
58
+ bubbles: true,
59
+ composed: true
60
+ })
61
+ );
62
+ }
63
+
64
+ @api
65
+ handleSecondaryClick() {
66
+ this.dismissBanner();
67
+ }
68
+
69
+ @api
70
+ handleCloseClick() {
71
+ this.dismissBanner();
72
+ }
73
+ }
@@ -43,6 +43,15 @@ export default class ContentLayout extends LightningElement {
43
43
  @api brand: any;
44
44
  @api emptyStateMessage?: string;
45
45
 
46
+ @api
47
+ get enableDataCloudSearch() {
48
+ return this._enableDataCloudSearch;
49
+ }
50
+ set enableDataCloudSearch(value) {
51
+ this._enableDataCloudSearch = normalizeBoolean(value);
52
+ }
53
+ private _enableDataCloudSearch = false;
54
+
46
55
  // This is needed for now to prevent failing snapshot tests due to links in the footer
47
56
  @api
48
57
  get showFooter() {
@@ -111,13 +120,19 @@ export default class ContentLayout extends LightningElement {
111
120
 
112
121
  /** Show Data 360 sidebar only when not using old sidebar and the page has searchable results. */
113
122
  protected get showDataCloudSidebar(): boolean {
114
- return !this.useOldSidebar && this.hasDataCloudResults === true;
123
+ return (
124
+ this.enableDataCloudSearch &&
125
+ !this.useOldSidebar &&
126
+ this.hasDataCloudResults === true
127
+ );
115
128
  }
116
129
 
117
130
  /** Show legacy sidebar when explicitly requested or when Data 360 has no results. Don't show until we know (avoids flash). */
118
131
  protected get showOldSidebar(): boolean {
119
132
  return (
120
- this.useOldSidebar === true || this.hasDataCloudResults === false
133
+ this.useOldSidebar === true ||
134
+ !this.enableDataCloudSearch ||
135
+ this.hasDataCloudResults === false
121
136
  );
122
137
  }
123
138
 
@@ -202,7 +217,7 @@ export default class ContentLayout extends LightningElement {
202
217
  }
203
218
 
204
219
  connectedCallback(): void {
205
- if (!this.useOldSidebar) {
220
+ if (this.enableDataCloudSearch && !this.useOldSidebar) {
206
221
  fetchHasResults().then((hasResults: boolean) => {
207
222
  this.hasDataCloudResults = hasResults;
208
223
  });
@@ -0,0 +1,3 @@
1
+ :host {
2
+ display: block;
3
+ }
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <doc-banner
3
+ message={bannerMessage}
4
+ button-label={bannerButtonLabel}
5
+ button-href={bannerButtonHref}
6
+ secondary-label={bannerSecondaryLabel}
7
+ dismiss-storage-key={dismissStorageKey}
8
+ ></doc-banner>
9
+ </template>
@@ -0,0 +1,195 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ interface LocaleStrings {
4
+ messageText: string;
5
+ linkUrl: string;
6
+ linkText: string;
7
+ buttonLabel: string;
8
+ secondaryLabel: string;
9
+ }
10
+
11
+ const DEFAULT_LOCALE = "en-us";
12
+
13
+ const LOCALE_STRINGS: Record<string, LocaleStrings> = {
14
+ "en-us": {
15
+ messageText:
16
+ "This text has been translated using Salesforce machine translation system. More details {link}.",
17
+ linkUrl:
18
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1",
19
+ linkText: "here",
20
+ buttonLabel: "Switch to English",
21
+ secondaryLabel: "Not Now"
22
+ },
23
+ "ja-jp": {
24
+ messageText:
25
+ "この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細は{link}をご参照ください。",
26
+ linkUrl:
27
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ja",
28
+ linkText: "こちら",
29
+ buttonLabel: "英語に切り替える",
30
+ secondaryLabel: "今はしません"
31
+ },
32
+ "zh-cn": {
33
+ messageText:
34
+ "此文本已使用 Salesforce 机器翻译系统进行翻译。如需了解更多详情,请点击{link}。",
35
+ linkUrl:
36
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=zh_CN",
37
+ linkText: "此处",
38
+ buttonLabel: "切换为英语",
39
+ secondaryLabel: "而非现在"
40
+ },
41
+ "zh-tw": {
42
+ messageText:
43
+ "此文已使用 Salesforce 機器翻譯系統翻譯。更多詳細資料請參見{link}。",
44
+ linkUrl:
45
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=zh_TW",
46
+ linkText: "此處",
47
+ buttonLabel: "切換至英文",
48
+ secondaryLabel: "不要現在"
49
+ },
50
+ "fr-fr": {
51
+ messageText:
52
+ "Ce texte a été traduit à l’aide du système de traduction automatique de Salesforce. Plus de détails, consultez {link}.",
53
+ linkUrl:
54
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=fr",
55
+ linkText: "cette page",
56
+ buttonLabel: "Basculer vers la page en anglais",
57
+ secondaryLabel: "Pas maintenant"
58
+ },
59
+ "de-de": {
60
+ messageText:
61
+ "Dieser Text wurde mit dem maschinellen Übersetzungssystem von Salesforce übersetzt. Weitere Details finden Sie {link}.",
62
+ linkUrl:
63
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=de",
64
+ linkText: "hier",
65
+ buttonLabel: "Zu Englisch wechseln",
66
+ secondaryLabel: "Nicht jetzt"
67
+ },
68
+ "it-it": {
69
+ messageText:
70
+ "Questo testo è stato tradotto utilizzando il sistema di traduzione automatica di Salesforce. Ulteriori dettagli sono disponibili {link}.",
71
+ linkUrl:
72
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=it",
73
+ linkText: "qui",
74
+ buttonLabel: "Passa all'inglese",
75
+ secondaryLabel: "Non ora"
76
+ },
77
+ "ko-kr": {
78
+ messageText:
79
+ "본 텍스트는 Salesforce 기계 번역 시스템으로 번역되었습니다. 자세한 내용은 {link}를 참조하세요.",
80
+ linkUrl:
81
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ko",
82
+ linkText: "여기",
83
+ buttonLabel: "영어로 전환",
84
+ secondaryLabel: "지금 안 함"
85
+ },
86
+ "pt-br": {
87
+ messageText:
88
+ "Este texto foi traduzido pelo sistema de tradução automática da Salesforce. Mais detalhes {link}.",
89
+ linkUrl:
90
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=pt_BR",
91
+ linkText: "aqui",
92
+ buttonLabel: "Alternar para inglês",
93
+ secondaryLabel: "Agora não"
94
+ },
95
+ "es-mx": {
96
+ messageText:
97
+ "Este texto se tradujo con el sistema de traducción automática de Salesforce. Obtenga más detalles {link}.",
98
+ linkUrl:
99
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=es_MX",
100
+ linkText: "aquí",
101
+ buttonLabel: "Cambiar a inglés",
102
+ secondaryLabel: "Ahora no"
103
+ },
104
+ "es-es": {
105
+ messageText:
106
+ "Este texto se ha traducido utilizando un sistema de traducción automática de Salesforce. Más información {link}.",
107
+ linkUrl:
108
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=es",
109
+ linkText: "aquí",
110
+ buttonLabel: "Cambiar a inglés",
111
+ secondaryLabel: "Ahora no"
112
+ },
113
+ "ru-ru": {
114
+ messageText:
115
+ "Данный текст был переведен при помощи системы машинного перевода Salesforce. Дополнительные сведения см. {link}.",
116
+ linkUrl:
117
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=ru",
118
+ linkText: "здесь",
119
+ buttonLabel: "Переключить на английский",
120
+ secondaryLabel: "Не сейчас"
121
+ },
122
+ "fi-fi": {
123
+ messageText:
124
+ "Tämä teksti on käännetty Salesforcen konekäännösjärjestelmän avulla. Katso lisätietoja {link}.",
125
+ linkUrl:
126
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=fi",
127
+ linkText: "täältä",
128
+ buttonLabel: "Vaihda englantiin",
129
+ secondaryLabel: "Ei nyt"
130
+ },
131
+ "da-dk": {
132
+ messageText:
133
+ "Denne tekst er oversat ved hjælp af Salesforce-maskinoversættelsessystem. Du finder flere detaljer {link}.",
134
+ linkUrl:
135
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=da",
136
+ linkText: "her",
137
+ buttonLabel: "Skift til engelsk",
138
+ secondaryLabel: "Ikke nu"
139
+ },
140
+ "sv-se": {
141
+ messageText:
142
+ "Den här texten har översatts med Salesforces maskinöversättningssystem. Mer information {link}.",
143
+ linkUrl:
144
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=sv",
145
+ linkText: "här",
146
+ buttonLabel: "Byt till engelska",
147
+ secondaryLabel: "Inte nu"
148
+ },
149
+ "nl-nl": {
150
+ messageText:
151
+ "Deze tekst werd vertaald aan de hand van het systeem voor automatische vertaling van Salesforce. U vindt {link} meer details.",
152
+ linkUrl:
153
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=nl_NL",
154
+ linkText: "hier",
155
+ buttonLabel: "Overschakelen op Engels",
156
+ secondaryLabel: "Niet nu"
157
+ },
158
+ "nb-no": {
159
+ messageText:
160
+ "Denne teksten er oversatt med Salesforce maskinoversettingssystem. Flere detaljer {link}.",
161
+ linkUrl:
162
+ "https://help.salesforce.com/s/articleView?id=000396076&type=1&language=no",
163
+ linkText: "her",
164
+ buttonLabel: "Bytt til engelsk",
165
+ secondaryLabel: "Ikke nå"
166
+ }
167
+ };
168
+
169
+ export default class LocaleBanner extends LightningElement {
170
+ @api locale = DEFAULT_LOCALE;
171
+ @api targetHref = "";
172
+ @api dismissStorageKey = "";
173
+
174
+ get localeData(): LocaleStrings {
175
+ return LOCALE_STRINGS[this.locale] || LOCALE_STRINGS[DEFAULT_LOCALE];
176
+ }
177
+
178
+ get bannerMessage(): string {
179
+ const data = this.localeData;
180
+ const link = `<a href="${data.linkUrl}">${data.linkText}</a>`;
181
+ return data.messageText.replace("{link}", link);
182
+ }
183
+
184
+ get bannerButtonLabel(): string {
185
+ return this.localeData.buttonLabel;
186
+ }
187
+
188
+ get bannerButtonHref(): string {
189
+ return this.targetHref;
190
+ }
191
+
192
+ get bannerSecondaryLabel(): string {
193
+ return this.localeData.secondaryLabel;
194
+ }
195
+ }
@@ -68,7 +68,10 @@
68
68
  </div>
69
69
  </div>
70
70
  <div lwc:if={showFooter} class="footer-container">
71
- <dx-footer variant="no-signup"></dx-footer>
71
+ <dx-footer
72
+ variant="no-signup"
73
+ mfe-config-origin={effectiveFooterOrigin}
74
+ ></dx-footer>
72
75
  </div>
73
76
  </div>
74
77
  </div>
@@ -1,3 +1,4 @@
1
+ import { api } from "lwc";
1
2
  import ContentLayout from "doc/contentLayout";
2
3
  import cx from "classnames";
3
4
 
@@ -15,6 +16,16 @@ export default class LwcContentLayout extends ContentLayout {
15
16
  private allTabsCache: any[] | null = null;
16
17
  private mainSlotCache: any = null;
17
18
 
19
+ /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer. */
20
+ @api origin: string | null = null;
21
+
22
+ /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
23
+ get effectiveFooterOrigin(): string {
24
+ return (
25
+ this.origin ?? `${window.location.origin}/developer/en-us/wp-json`
26
+ );
27
+ }
28
+
18
29
  private setRNBByTab() {
19
30
  const tabPanelListItem = this.getTabPanelList();
20
31
  this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB;
@@ -68,6 +68,16 @@ export default class RedocReference extends LightningElement {
68
68
  this._parentDocPhaseInfo = value;
69
69
  }
70
70
 
71
+ /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer. */
72
+ @api origin: string | null = null;
73
+
74
+ /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
75
+ get effectiveFooterOrigin(): string {
76
+ return (
77
+ this.origin ?? `${window.location.origin}/developer/en-us/wp-json`
78
+ );
79
+ }
80
+
71
81
  connectedCallback(): void {
72
82
  window.addEventListener("scroll", this.handleScrollAndResize);
73
83
  window.addEventListener("resize", this.handleScrollAndResize);
@@ -338,7 +348,7 @@ export default class RedocReference extends LightningElement {
338
348
  // Appends footer component to container
339
349
  private insertFooter(container: HTMLElement): void {
340
350
  const footerElement = createElement("dx-footer", { is: DxFooter });
341
- Object.assign(footerElement, { variant: "no-signup" });
351
+ Object.assign(footerElement, { variant: "no-signup", mfeConfigOrigin: this.effectiveFooterOrigin });
342
352
  container.appendChild(footerElement);
343
353
  }
344
354
 
@@ -2,6 +2,7 @@
2
2
  <doc-content-layout
3
3
  lwc:if={displayContent}
4
4
  lwc:ref="docContentLayout"
5
+ enable-data-cloud-search
5
6
  sidebar-header={docTitle}
6
7
  sidebar-content={sidebarContent}
7
8
  sidebar-value={sidebarValue}
@@ -53,7 +54,7 @@
53
54
  </doc-content-layout>
54
55
  <div lwc:if={display404}>
55
56
  <dx-error
56
- image="https://a.sfdcstatic.com/developer-website/prod/images/404.svg"
57
+ image="https://developer.salesforce.com/ns-assets/404.svg"
57
58
  code="404"
58
59
  header="Beep boop. That did not compute."
59
60
  subtitle="The document you're looking for doesn't seem to exist."
@@ -48,6 +48,9 @@ export default class DocXmlContent extends LightningElementWithState<{
48
48
  /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). Passed through to dx-footer-mfe. */
49
49
  @api origin: string | null = null;
50
50
 
51
+ /** Optional base URL for the canonical link (e.g. https://developer.salesforce.com). When set, used instead of window.location for the canonical href. */
52
+ @api baseUrl: string | null = null;
53
+
51
54
  @api
52
55
  get allLanguages(): Array<Language> {
53
56
  return this._allLanguages;
@@ -308,8 +311,10 @@ export default class DocXmlContent extends LightningElementWithState<{
308
311
  };
309
312
  }
310
313
 
311
- private handlePopState = (event: PopStateEvent): void =>
314
+ private handlePopState = (event: PopStateEvent): void => {
312
315
  this.updatePageReference(this.getReferenceFromUrl(), event);
316
+ this.handleLocaleReload();
317
+ };
313
318
 
314
319
  handleDismissVersionBanner() {
315
320
  this.showVersionBanner = false;
@@ -584,6 +589,31 @@ export default class DocXmlContent extends LightningElementWithState<{
584
589
  "docs",
585
590
  this.pageReferenceToString(this.pageReference)
586
591
  );
592
+ this.handleLocaleReload();
593
+ }
594
+
595
+ /* This method reloads the page as locale banner context is not available in developer-website. */
596
+ private handleLocaleReload(): void {
597
+ const targetLocale = this.language?.id;
598
+ if (!targetLocale) {
599
+ return;
600
+ }
601
+
602
+ const currentPath = window.location.pathname;
603
+ const localePattern = /atlas\.[a-z]{2}-[a-z]{2}\./;
604
+
605
+ if (localePattern.test(currentPath)) {
606
+ const newPath = currentPath.replace(
607
+ localePattern,
608
+ `atlas.${targetLocale}.`
609
+ );
610
+ const newUrl =
611
+ window.location.origin +
612
+ newPath +
613
+ window.location.search +
614
+ window.location.hash;
615
+ window.location.href = newUrl;
616
+ }
587
617
  }
588
618
 
589
619
  private updateHighlighting(searchParam: string): void {
@@ -755,21 +785,19 @@ export default class DocXmlContent extends LightningElementWithState<{
755
785
  }
756
786
 
757
787
  if (this.pageReference) {
758
- const metadescription = document.querySelector(
788
+ const canonicalLink = document.querySelector(
759
789
  'link[rel="canonical"]'
760
790
  );
761
- if (metadescription) {
791
+ if (canonicalLink) {
762
792
  const copyPageReference = { ...this.pageReference };
763
793
  copyPageReference.docId = copyPageReference.docId
764
794
  ? this.dropVersionFromDocId(copyPageReference.docId)
765
795
  : copyPageReference.docId;
766
- metadescription.setAttribute(
767
- "href",
768
- window.location.protocol +
769
- "//" +
770
- window.location.host +
771
- this.pageReferenceToString(copyPageReference)
772
- );
796
+ const path = this.pageReferenceToString(copyPageReference);
797
+ const origin = this.baseUrl
798
+ ? this.baseUrl.replace(/\/$/, "")
799
+ : `${window.location.protocol}//${window.location.host}`;
800
+ canonicalLink.setAttribute("href", `${origin}${path}`);
773
801
  }
774
802
  }
775
803