@salesforcedevs/dw-components 1.17.0 → 1.17.7

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/dw-components",
3
- "version": "1.17.0",
3
+ "version": "1.17.7",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -26,5 +26,5 @@
26
26
  "@types/setimmediate": "1.0.4",
27
27
  "setimmediate": "1.0.5"
28
28
  },
29
- "gitHead": "1ffac16d66295e04f390e3240328e7f7a9541268"
29
+ "gitHead": "db30a6d981a6c175ffbf875d8aab522361d35809"
30
30
  }
@@ -2,6 +2,7 @@ import { api, LightningElement } from "lwc";
2
2
 
3
3
  import { CodeSample } from "typings/custom";
4
4
  import { toJson } from "dxUtils/normalizers";
5
+ import { track } from "dxUtils/analytics";
5
6
 
6
7
  const DEFAULT_BUTTON_TEXT = "Explore on GitHub";
7
8
  export default class CodeSamplesGrid extends LightningElement {
@@ -66,4 +67,18 @@ export default class CodeSamplesGrid extends LightningElement {
66
67
  this.deviceType = "mobile-small";
67
68
  }
68
69
  };
70
+
71
+ handleReadItClick(event: any) {
72
+ track(document, "custEv_ctaButtonClick", {
73
+ click_text: event.currentTarget.innerText,
74
+ item_title: event.currentTarget.innerText,
75
+ click_url: `${
76
+ event.currentTarget.href.includes("http")
77
+ ? event.currentTarget.href
78
+ : window.location.origin + event.currentTarget.href
79
+ }`,
80
+ element_type: "button",
81
+ content_category: "cta"
82
+ });
83
+ }
69
84
  }
@@ -11,6 +11,12 @@ const language_local_names_map: any = {
11
11
  japanese: "日本語",
12
12
  english: "English"
13
13
  };
14
+
15
+ const language_codes_map: any = {
16
+ japanese: "ja",
17
+ english: "en"
18
+ };
19
+
14
20
  const DEFAULT = language_local_names_map.english;
15
21
 
16
22
  interface ACF {
@@ -55,10 +61,26 @@ export default class LanguageSelector extends LightningElement {
55
61
  )
56
62
  ).json();
57
63
 
64
+ // Remove existing hreflang links to avoid duplicates
65
+ const existingLinks = document.querySelectorAll("link[hreflang]");
66
+ existingLinks.forEach((link) => link.remove());
67
+
58
68
  Object.values(alternatePosts).forEach((post: Post) => {
59
69
  const localLanguageName =
60
70
  this.getLanguageOrDefaultIfInvalid(post);
61
- this._languageMap[localLanguageName] = normalizePostLink(post);
71
+ const url = normalizePostLink(post);
72
+ this._languageMap[localLanguageName] = url;
73
+
74
+ // Add hreflang link for this language
75
+ const languageCode =
76
+ language_codes_map[post.acf.language || "english"];
77
+ if (languageCode && url) {
78
+ const link = document.createElement("link");
79
+ link.rel = "alternate";
80
+ link.hreflang = languageCode;
81
+ link.href = url;
82
+ document.head.appendChild(link);
83
+ }
62
84
  });
63
85
 
64
86
  this.languages = Object.values(alternatePosts).map((post) => {