@salesforcedevs/docs-components 0.54.0 → 0.54.1-a01

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.
Files changed (44) hide show
  1. package/lwc.config.json +6 -2
  2. package/package.json +12 -4
  3. package/src/modules/README.md +41 -0
  4. package/src/modules/doc/amfReference/amfReference.css +5 -0
  5. package/src/modules/doc/amfReference/amfReference.html +47 -0
  6. package/src/modules/doc/amfReference/amfReference.ts +1309 -0
  7. package/src/modules/doc/amfReference/constants.ts +76 -0
  8. package/src/modules/doc/amfReference/types.ts +133 -0
  9. package/src/modules/doc/amfReference/utils.ts +669 -0
  10. package/src/modules/doc/amfTopic/amfTopic.css +1 -0
  11. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  12. package/src/modules/doc/amfTopic/amfTopic.ts +94 -0
  13. package/src/modules/doc/amfTopic/types.ts +54 -0
  14. package/src/modules/doc/amfTopic/utils.ts +130 -0
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +4 -3
  16. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +1 -1
  17. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +17 -1
  18. package/src/modules/doc/breadcrumbs/breadcrumbs.css +11 -3
  19. package/src/modules/doc/breadcrumbs/breadcrumbs.html +12 -2
  20. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +50 -9
  21. package/src/modules/doc/content/content.css +35 -11
  22. package/src/modules/doc/content/content.ts +18 -3
  23. package/src/modules/doc/contentCallout/contentCallout.css +4 -4
  24. package/src/modules/doc/contentCallout/contentCallout.ts +5 -0
  25. package/src/modules/doc/contentLayout/contentLayout.css +98 -0
  26. package/src/modules/doc/contentLayout/contentLayout.html +48 -0
  27. package/src/modules/doc/contentLayout/contentLayout.ts +287 -0
  28. package/src/modules/doc/header/header.css +1 -1
  29. package/src/modules/doc/header/header.ts +5 -5
  30. package/src/modules/doc/headingAnchor/headingAnchor.css +1 -1
  31. package/src/modules/doc/headingContent/headingContent.css +5 -1
  32. package/src/modules/doc/phase/phase.css +3 -3
  33. package/src/modules/doc/phase/phase.ts +1 -1
  34. package/src/modules/doc/xmlContent/types.ts +114 -0
  35. package/src/modules/doc/xmlContent/utils.ts +161 -0
  36. package/src/modules/doc/xmlContent/xmlContent.css +32 -0
  37. package/src/modules/doc/xmlContent/xmlContent.html +39 -0
  38. package/src/modules/doc/xmlContent/xmlContent.ts +651 -0
  39. package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
  40. package/src/modules/docHelpers/amfStyle/amfStyle.css +390 -0
  41. package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +39 -0
  42. package/src/modules/{helpers → docHelpers}/status/status.css +0 -0
  43. package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +85 -0
  44. package/LICENSE +0 -12
@@ -0,0 +1,651 @@
1
+ import { api, track } from "lwc";
2
+ import { normalizeBoolean } from "dxUtils/normalizers";
3
+ import { FetchContent } from "./utils";
4
+ import {
5
+ CoveoAdvancedQueryXMLConfig,
6
+ DocLanguage,
7
+ DocVersion,
8
+ TreeNode,
9
+ Header,
10
+ HistoryState,
11
+ PageReference,
12
+ TocMap
13
+ } from "./types";
14
+ import { SearchSyncer } from "docUtils/SearchSyncer";
15
+ import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
16
+ import { Breadcrumb, Language } from "typings/custom";
17
+
18
+ // TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
19
+ const handleContentError = (error): void => console.log(error);
20
+
21
+ const FIRST_CRUMB = {
22
+ href: "/docs",
23
+ label: "Documentation"
24
+ };
25
+
26
+ const PIXEL_PER_CHARACTER_MAP: { [key: string]: number } = {
27
+ default: 7.7,
28
+ "ja-jp": 12.5
29
+ };
30
+
31
+ export default class DocXmlContent extends LightningElementWithState<{
32
+ isFetchingDocument: boolean;
33
+ isFetchingContent: boolean;
34
+ lastHighlightedSearch: string;
35
+ }> {
36
+ @api apiDomain = "https://developer.salesforce.com";
37
+ @api coveoOrganizationId!: string;
38
+ @api coveoPublicAccessToken!: string;
39
+
40
+ @api
41
+ get allLanguages(): Array<Language> {
42
+ return this._allLanguages;
43
+ }
44
+
45
+ set allLanguages(value: string) {
46
+ if (value) {
47
+ this._allLanguages = JSON.parse(value);
48
+ }
49
+ }
50
+
51
+ @api
52
+ get enableCoveo() {
53
+ return this._enableCoveo;
54
+ }
55
+
56
+ set enableCoveo(value) {
57
+ this._enableCoveo = normalizeBoolean(value);
58
+ }
59
+
60
+ private availableLanguages: Array<DocLanguage> = [];
61
+ private availableVersions: Array<DocVersion> = [];
62
+ private contentProvider: FetchContent;
63
+ private docContent = "";
64
+ private language: DocLanguage = null;
65
+ private loaded = false;
66
+ private pdfUrl = "";
67
+ private tocMap: TocMap = {};
68
+ private sidebarContent: Array<TreeNode> = null;
69
+ private version: DocVersion = null;
70
+ private docTitle = "";
71
+ private analyticsEvent = "custEv_ctaLinkClick";
72
+ private _pathName = "";
73
+ private _pageHeader?: Header;
74
+ private listenerAttached = false;
75
+ private _enableCoveo?: boolean = false;
76
+
77
+ private searchSyncer = new SearchSyncer({
78
+ callbacks: {
79
+ onSearchChange: (nextSearchString: string): void => {
80
+ if (nextSearchString !== this.pageReference.search) {
81
+ this.updatePageReference({
82
+ ...this.pageReference,
83
+ search: nextSearchString
84
+ });
85
+ }
86
+ if (nextSearchString !== this.state.lastHighlightedSearch) {
87
+ this.updateHighlighting(
88
+ new URLSearchParams(nextSearchString).get("q") || ""
89
+ );
90
+ }
91
+ },
92
+ onUrlChange: (nextSearchString: string): void => {
93
+ if (nextSearchString !== this.pageReference.search) {
94
+ this.updatePageReference({
95
+ ...this.pageReference,
96
+ search: nextSearchString
97
+ });
98
+ }
99
+ const nextSearchParam =
100
+ new URLSearchParams(nextSearchString).get("q") || "";
101
+ this.updateSearchInput(nextSearchParam);
102
+ if (nextSearchString !== this.state.lastHighlightedSearch) {
103
+ this.updateHighlighting(nextSearchParam);
104
+ }
105
+ }
106
+ },
107
+ eventName: "sidebarsearchchange",
108
+ historyMethod: window.history.pushState,
109
+ searchParam: "q",
110
+ shouldStopPropagation: true,
111
+ target: window
112
+ });
113
+ private _allLanguages: Array<Language> = [];
114
+
115
+ @track private pageReference: PageReference = {};
116
+ @track breadcrumbs: Array<Breadcrumb> = [];
117
+
118
+ constructor() {
119
+ super();
120
+ this.pageReference = this.getReferenceFromUrl();
121
+ // In order to prevent dispatching unnecessary highlight changes, we
122
+ // track these items and use their previous values for comparisons in
123
+ // `renderedCallback`:
124
+ this.state = {
125
+ isFetchingContent: false,
126
+ isFetchingDocument: false,
127
+ lastHighlightedSearch: "",
128
+ internalLinkClicked: false
129
+ };
130
+ }
131
+
132
+ connectedCallback(): void {
133
+ if (!this.pageReference?.deliverable) {
134
+ window.location.href = "/docs";
135
+ return;
136
+ }
137
+ this.contentProvider = new FetchContent(
138
+ this.apiDomain,
139
+ this.allLanguages
140
+ );
141
+ this.fetchDocument().then(() => (this.loaded = true));
142
+ window.addEventListener("popstate", this.handlePopState);
143
+
144
+ this.searchSyncer.init();
145
+ }
146
+
147
+ renderedCallback(): void {
148
+ this.setState({ internalLinkClicked: true });
149
+ const urlSectionLink =
150
+ this.pageReference?.hash?.split("#").length > 1
151
+ ? this.pageReference.hash.split("#")[1]
152
+ : this.pageReference?.hash;
153
+
154
+ const contentEl = this.template.querySelector("doc-content");
155
+ const anchorEl =
156
+ urlSectionLink &&
157
+ (contentEl?.shadowRoot?.querySelector(`[id='${urlSectionLink}']`) ||
158
+ contentEl?.shadowRoot?.querySelector(
159
+ `[name='${urlSectionLink}']`
160
+ ));
161
+
162
+ if (anchorEl) {
163
+ anchorEl.scrollIntoView();
164
+ this.setState({ internalLinkClicked: false });
165
+ }
166
+
167
+ if (
168
+ (this.prevState.isFetchingContent &&
169
+ !this.state.isFetchingContent) ||
170
+ (this.prevState.isFetchingDocument &&
171
+ !this.state.isFetchingDocument)
172
+ ) {
173
+ const prevSearchParam =
174
+ new URLSearchParams(this.state.lastHighlightedSearch).get(
175
+ "q"
176
+ ) || "";
177
+ const nextSearchParam =
178
+ new URLSearchParams(this.pageReference.search).get("q") || "";
179
+ this.updateHighlighting(nextSearchParam);
180
+ if (prevSearchParam !== nextSearchParam) {
181
+ this.updateSearchInput(nextSearchParam);
182
+ }
183
+ }
184
+ }
185
+
186
+ disconnectedCallback(): void {
187
+ window.removeEventListener("popstate", this.handlePopState);
188
+ this.searchSyncer.dispose();
189
+ if (this.listenerAttached) {
190
+ this.pageHeader.removeEventListener(
191
+ "langchange",
192
+ this.handleLanguageChange
193
+ );
194
+ this.listenerAttached = false;
195
+ }
196
+ }
197
+
198
+ private get languageId(): string {
199
+ return this.language.id.replace("-", "_");
200
+ }
201
+
202
+ private get releaseVersionId(): string {
203
+ return this.version.id;
204
+ }
205
+
206
+ private get deliverable(): string {
207
+ return this.pageReference.deliverable;
208
+ }
209
+
210
+ private get useOldSidebar(): boolean {
211
+ // Coveo is enabled and the version is greater than 51 (within the latest 3 versions)
212
+ // TODO: we need a better fix for version number check
213
+ return !(
214
+ this.enableCoveo &&
215
+ this.coveoOrganizationId &&
216
+ this.coveoPublicAccessToken &&
217
+ (!this.version?.releaseVersion ||
218
+ (this.version?.releaseVersion &&
219
+ parseInt(
220
+ this.version.releaseVersion.replace("v", ""),
221
+ 10
222
+ ) >= 53))
223
+ );
224
+ }
225
+
226
+ private get coveoAdvancedQueryConfig(): CoveoAdvancedQueryXMLConfig {
227
+ const config: { locale: string; topicid: string; version?: string } = {
228
+ locale: this.languageId,
229
+ topicid: this.deliverable
230
+ };
231
+
232
+ if (this.releaseVersionId && this.releaseVersionId !== "noversion") {
233
+ config.version = this.releaseVersionId;
234
+ }
235
+
236
+ return config;
237
+ }
238
+
239
+ private get pageHeader(): Header {
240
+ if (!this._pageHeader) {
241
+ this._pageHeader = document.querySelector("doc-header");
242
+ }
243
+
244
+ return this._pageHeader;
245
+ }
246
+
247
+ private get sidebarValue(): string {
248
+ if (this.pageReference?.contentDocumentId) {
249
+ const hashedUri = `${
250
+ this.pageReference.contentDocumentId
251
+ }${this.normalizeHash(this.pageReference.hash)}`;
252
+ if (hashedUri in this.tocMap) {
253
+ return hashedUri;
254
+ }
255
+
256
+ if (this.pageReference.contentDocumentId in this.tocMap) {
257
+ return this.pageReference.contentDocumentId;
258
+ }
259
+ }
260
+
261
+ return "";
262
+ }
263
+
264
+ private get disableVersion(): boolean {
265
+ return !this.availableVersions || this.availableVersions.length <= 1;
266
+ }
267
+
268
+ private get versionOptions(): Array<DocVersion> {
269
+ return this.disableVersion
270
+ ? this.availableVersions
271
+ : this.availableVersions.map((version) => ({
272
+ ...version,
273
+ link: {
274
+ href: this.pageReferenceToString({
275
+ ...this.pageReference,
276
+ docId: version.url
277
+ })
278
+ }
279
+ }));
280
+ }
281
+
282
+ private get breadcrumbPixelPerCharacter() {
283
+ return (
284
+ PIXEL_PER_CHARACTER_MAP[this.language.id] ||
285
+ PIXEL_PER_CHARACTER_MAP.default
286
+ );
287
+ }
288
+
289
+ private handlePopState = (): void =>
290
+ this.updatePageReference(this.getReferenceFromUrl());
291
+
292
+ handleSelect(event: CustomEvent<{ name: string }>): void {
293
+ event.stopPropagation();
294
+ const { name } = event.detail;
295
+
296
+ if (this.sidebarValue === name) {
297
+ return;
298
+ }
299
+
300
+ if (name) {
301
+ const hashIndex = name.indexOf("#");
302
+ const hash = hashIndex > -1 ? name.slice(hashIndex) : "";
303
+
304
+ const contentDocumentId =
305
+ hashIndex > -1 ? name.slice(0, hashIndex) : name;
306
+ this.updatePageReference({
307
+ ...this.pageReference,
308
+ contentDocumentId,
309
+ hash
310
+ });
311
+ this.updateUrl();
312
+ }
313
+ }
314
+
315
+ handleNavClick(event: CustomEvent<{ pageReference: PageReference }>): void {
316
+ event.stopPropagation();
317
+ const { pageReference } = event.detail;
318
+ this.updatePageReference(pageReference);
319
+ this.updateUrl();
320
+ }
321
+
322
+ handleLanguageChange = (event: CustomEvent<string>): Promise<void> => {
323
+ if (this.language && this.language.id === event.detail) {
324
+ return;
325
+ }
326
+
327
+ this.language = this.availableLanguages.find(
328
+ ({ id }) => id === event.detail
329
+ );
330
+ this.pageReference.docId = this.language.url;
331
+ this.updateUrl();
332
+ this.fetchDocument();
333
+ };
334
+
335
+ updatePageReference(newPageReference: PageReference): void {
336
+ this.pageReference.hash = newPageReference.hash;
337
+ this.pageReference.search = newPageReference.search;
338
+
339
+ if (this.isSamePage(newPageReference)) {
340
+ return;
341
+ }
342
+
343
+ const isSameDocId = this.pageReference.docId === newPageReference.docId;
344
+ this.pageReference = newPageReference;
345
+
346
+ if (!isSameDocId) {
347
+ this.fetchDocument();
348
+ return;
349
+ }
350
+
351
+ this.fetchContent()
352
+ .then(() => this.buildBreadcrumbs())
353
+ .catch(handleContentError);
354
+ }
355
+
356
+ getReferenceFromUrl(): PageReference {
357
+ const [page, docId, deliverable, contentDocumentId] =
358
+ window.location.pathname.substr(1).split("/");
359
+
360
+ const { origin: domain, hash, search } = window.location;
361
+
362
+ return {
363
+ contentDocumentId,
364
+ deliverable,
365
+ docId,
366
+ domain,
367
+ hash,
368
+ page,
369
+ search
370
+ };
371
+ }
372
+
373
+ isSamePage(reference: PageReference): boolean {
374
+ return (
375
+ this.pageReference.contentDocumentId ===
376
+ reference.contentDocumentId &&
377
+ this.pageReference.docId === reference.docId &&
378
+ this.pageReference.page === reference.page &&
379
+ this.pageReference.deliverable === reference.deliverable
380
+ );
381
+ }
382
+
383
+ async fetchDocument(): Promise<void> {
384
+ this.setState({
385
+ isFetchingDocument: true
386
+ });
387
+ const data = await this.contentProvider.fetchDocumentData(
388
+ this.pageReference.docId
389
+ );
390
+
391
+ // This could be a 404 scenario.
392
+ if (!data) {
393
+ this.setState({
394
+ isFetchingDocument: false
395
+ });
396
+ return;
397
+ }
398
+
399
+ this.docTitle = data.docTitle;
400
+ this.tocMap = data.tocMap;
401
+ this.sidebarContent = data.toc;
402
+ this.version = data.version;
403
+ this.language = data.language;
404
+ this.availableLanguages = data.availableLanguages;
405
+ this.availableVersions = data.availableVersions;
406
+ this.pdfUrl = data.pdfUrl;
407
+
408
+ this.updateHeader();
409
+
410
+ this.buildBreadcrumbs();
411
+
412
+ if (this.pageReference.deliverable !== data.deliverable) {
413
+ this.pageReference.deliverable = data.deliverable;
414
+ this.updateUrl(HistoryState.REPLACE_STATE);
415
+ }
416
+
417
+ if (
418
+ this.pageReference?.contentDocumentId?.replace(/\.htm$/, "") !==
419
+ data.id
420
+ ) {
421
+ try {
422
+ await this.fetchContent();
423
+ this.setState({
424
+ isFetchingDocument: false
425
+ });
426
+ return;
427
+ } catch (error) {
428
+ this.pageReference.contentDocumentId = `${data.id}.htm`;
429
+ this.pageReference.hash = "";
430
+ this.pageReference.search = "";
431
+ this.updateUrl(HistoryState.REPLACE_STATE);
432
+ }
433
+ }
434
+
435
+ this.docContent = data.content;
436
+ this.addMetatags();
437
+ this.setState({
438
+ isFetchingDocument: false
439
+ });
440
+ }
441
+
442
+ async fetchContent(): Promise<void> {
443
+ this.setState({
444
+ isFetchingContent: true
445
+ });
446
+ const data = await this.contentProvider.fetchContent(
447
+ this.pageReference.deliverable,
448
+ this.pageReference.contentDocumentId,
449
+ {
450
+ language: this.language.id,
451
+ version: this.version.id
452
+ }
453
+ );
454
+
455
+ if (data) {
456
+ this.docContent = data.content;
457
+ this.addMetatags();
458
+
459
+ if (!this.pageReference.hash) {
460
+ document.querySelector("main")?.scrollIntoView({
461
+ behavior: "smooth",
462
+ block: "start",
463
+ inline: "nearest"
464
+ });
465
+ }
466
+ }
467
+ this.setState({
468
+ isFetchingContent: false
469
+ });
470
+ }
471
+
472
+ updateHeader(): void {
473
+ if (!this.pageHeader) {
474
+ return;
475
+ }
476
+
477
+ if (this.docTitle) {
478
+ this.pageHeader.subtitle = this.docTitle;
479
+ }
480
+
481
+ if (this.pdfUrl) {
482
+ this.pageHeader.bailHref = this.pdfUrl;
483
+ this.pageHeader.bailLabel = "PDF";
484
+ }
485
+
486
+ if (!this.listenerAttached) {
487
+ this.pageHeader.addEventListener(
488
+ "langchange",
489
+ this.handleLanguageChange
490
+ );
491
+ this.listenerAttached = true;
492
+ }
493
+
494
+ this.pageHeader.languages = this.availableLanguages;
495
+ this.pageHeader.language = this.language?.id;
496
+
497
+ if (this.pageReference) {
498
+ const { docId, deliverable, page } = this.pageReference;
499
+ this.pageHeader.headerHref = `/${page}/${docId}/${deliverable}/`;
500
+ }
501
+ }
502
+
503
+ updateUrl(method = HistoryState.PUSH_STATE): void {
504
+ window.history[method](
505
+ {},
506
+ "docs",
507
+ this.pageReferenceToString(this.pageReference)
508
+ );
509
+ }
510
+
511
+ private updateHighlighting(searchParam: string): void {
512
+ this.dispatchHighlightChange(searchParam);
513
+ this.setState({
514
+ lastHighlightedSearch: this.pageReference.search
515
+ });
516
+ }
517
+
518
+ private updateSearchInput(searchParam: string): void {
519
+ this.template
520
+ .querySelector("doc-content-layout")
521
+ ?.setSidebarInputValue(searchParam);
522
+ }
523
+
524
+ private pageReferenceToString(reference: PageReference): string {
525
+ const { page, docId, deliverable, contentDocumentId, hash, search } =
526
+ reference;
527
+ return `/${page}/${docId}/${deliverable}/${contentDocumentId}${this.normalizeSearch(
528
+ search
529
+ )}${this.normalizeHash(hash)}`;
530
+ }
531
+
532
+ private normalizeUrlPart(part: string, sentinel: string): string {
533
+ return (
534
+ (part &&
535
+ (part.startsWith(sentinel) ? part : `${sentinel}${part}`)) ||
536
+ ""
537
+ );
538
+ }
539
+
540
+ private normalizeSearch(search: string): string {
541
+ return this.normalizeUrlPart(search, "?");
542
+ }
543
+
544
+ private normalizeHash(hash: string): string {
545
+ return this.normalizeUrlPart(hash, "#");
546
+ }
547
+
548
+ private getComposedTitle(
549
+ topicTitle: string | undefined,
550
+ docTitle: string | undefined
551
+ ): string {
552
+ // map to avoid duplicates
553
+ const titleMap = {};
554
+ if (topicTitle) {
555
+ // sometimes the h1 tag text (which is docSubTitle) contains text with new line character. For e.g, "Bulk API 2.0 Older\n Documentation",
556
+ // here it contains \n in the text context which needs to be removed
557
+ // also, there are multiple spaces in between the text, which needs to be replaced with a single space
558
+ const docTopicTitle = topicTitle
559
+ .replace(/[\t\r\n]/g, " ")
560
+ .replace(/ +/g, " ")
561
+ .trim();
562
+ titleMap[docTopicTitle] = true;
563
+ }
564
+
565
+ if (docTitle) {
566
+ titleMap[docTitle] = true;
567
+ }
568
+
569
+ titleMap["Salesforce Developers"] = true;
570
+
571
+ return Object.keys(titleMap).join(" | ");
572
+ }
573
+
574
+ private dispatchHighlightChange(term: string): void {
575
+ this.dispatchEvent(
576
+ new CustomEvent("highlightedtermchange", {
577
+ detail: term,
578
+ bubbles: true,
579
+ composed: true
580
+ })
581
+ );
582
+ }
583
+
584
+ private buildBreadcrumbs(): void {
585
+ const { contentDocumentId } = this.pageReference;
586
+ if (!contentDocumentId) {
587
+ return;
588
+ }
589
+
590
+ const currentNode = this.tocMap[contentDocumentId];
591
+ this.breadcrumbs = this.nodeToBreadcrumb(currentNode);
592
+ }
593
+
594
+ private nodeToBreadcrumb(node?: TreeNode): Breadcrumb[] {
595
+ if (!node) {
596
+ return [FIRST_CRUMB];
597
+ }
598
+ return [
599
+ ...this.nodeToBreadcrumb(node.parent),
600
+ {
601
+ href: this.pageReferenceToString({
602
+ ...this.pageReference,
603
+ contentDocumentId: node.name
604
+ }),
605
+ label: node.label
606
+ }
607
+ ];
608
+ }
609
+
610
+ addMetatags(): void {
611
+ const div = document.createElement("div");
612
+ div.innerHTML = this.docContent;
613
+ const docDescription = div.querySelector(".shortdesc")?.textContent;
614
+ const topicTitle = div.querySelector("h1")?.textContent;
615
+
616
+ const title = document.querySelector("title");
617
+ const composedTitle = this.getComposedTitle(topicTitle, this.docTitle);
618
+
619
+ if (title) {
620
+ title.textContent = composedTitle;
621
+ }
622
+ const metatitle = document.querySelector('meta[name="title"]');
623
+ if (metatitle) {
624
+ metatitle.setAttribute("content", composedTitle);
625
+ }
626
+
627
+ if (docDescription) {
628
+ const metadescription = document.querySelector(
629
+ 'meta[name="description"]'
630
+ );
631
+ if (metadescription) {
632
+ metadescription.setAttribute("content", docDescription);
633
+ }
634
+ }
635
+
636
+ if (this.pageReference) {
637
+ const metadescription = document.querySelector(
638
+ 'link[rel="canonical"]'
639
+ );
640
+ if (metadescription) {
641
+ metadescription.setAttribute(
642
+ "href",
643
+ window.location.protocol +
644
+ "//" +
645
+ window.location.host +
646
+ this.pageReferenceToString(this.pageReference)
647
+ );
648
+ }
649
+ }
650
+ }
651
+ }