@salesforcedevs/docs-components 1.27.23 → 1.27.24

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.27.23",
3
+ "version": "1.27.24",
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": "cf0bd3ee04b82cfaea087d3db0025a0243f7cfb2"
28
+ "gitHead": "48921f68f82d211591241267ed65276fcbb077ed"
29
29
  }
@@ -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;
@@ -766,21 +769,19 @@ export default class DocXmlContent extends LightningElementWithState<{
766
769
  }
767
770
 
768
771
  if (this.pageReference) {
769
- const metadescription = document.querySelector(
772
+ const canonicalLink = document.querySelector(
770
773
  'link[rel="canonical"]'
771
774
  );
772
- if (metadescription) {
775
+ if (canonicalLink) {
773
776
  const copyPageReference = { ...this.pageReference };
774
777
  copyPageReference.docId = copyPageReference.docId
775
778
  ? this.dropVersionFromDocId(copyPageReference.docId)
776
779
  : copyPageReference.docId;
777
- metadescription.setAttribute(
778
- "href",
779
- window.location.protocol +
780
- "//" +
781
- window.location.host +
782
- this.pageReferenceToString(copyPageReference)
783
- );
780
+ const path = this.pageReferenceToString(copyPageReference);
781
+ const origin = this.baseUrl
782
+ ? this.baseUrl.replace(/\/$/, "")
783
+ : `${window.location.protocol}//${window.location.host}`;
784
+ canonicalLink.setAttribute("href", `${origin}${path}`);
784
785
  }
785
786
  }
786
787