@salesforcedevs/docs-components 0.56.2-seo-test11 → 0.56.2-seo-test15

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": "0.56.2-seo-test11",
3
+ "version": "0.56.2-seo-test15",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -220,13 +220,14 @@ export default class AmfReference extends LightningElement {
220
220
  if (strippedHashItems.length) {
221
221
  const referenceId = strippedHashItems[0];
222
222
  const meta = strippedHashItems[1];
223
+ const encodedMeta = this.getUrlEncoded(meta);
223
224
  const updatedReferenceId =
224
225
  oldReferenceIdNewReferenceIdMap[referenceId];
225
226
  const newReferenceId = updatedReferenceId || referenceId;
226
227
  const referenceItemConfig =
227
228
  this.getAmfConfigWithId(newReferenceId);
228
229
  if (referenceItemConfig) {
229
- hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${meta}`;
230
+ hashBasedRedirectUrl = `${referenceItemConfig.href}?meta=${encodedMeta}`;
230
231
  }
231
232
  }
232
233
  }
@@ -481,7 +482,8 @@ export default class AmfReference extends LightningElement {
481
482
  parentReferencePath: string,
482
483
  meta: string
483
484
  ): string {
484
- return meta ? `${parentReferencePath}?meta=${meta}` : "";
485
+ const encodedMeta = meta ? this.getUrlEncoded(meta) : "";
486
+ return encodedMeta ? `${parentReferencePath}?meta=${encodedMeta}` : "";
485
487
  }
486
488
 
487
489
  /**
@@ -558,8 +560,8 @@ export default class AmfReference extends LightningElement {
558
560
  return typeALbl < typeBLbl
559
561
  ? -1
560
562
  : typeALbl > typeBLbl
561
- ? 1
562
- : 0;
563
+ ? 1
564
+ : 0;
563
565
  });
564
566
  }
565
567
  // eslint-disable-next-line no-fallthrough
@@ -731,10 +733,11 @@ export default class AmfReference extends LightningElement {
731
733
  meta?: string
732
734
  ): void {
733
735
  if (meta) {
736
+ const encodedMeta = this.getUrlEncoded(meta);
734
737
  window.history.pushState(
735
738
  {},
736
739
  "",
737
- `${parentReferencePath}?meta=${meta}`
740
+ `${parentReferencePath}?meta=${encodedMeta}`
738
741
  );
739
742
  }
740
743
  }
@@ -747,10 +750,11 @@ export default class AmfReference extends LightningElement {
747
750
  meta?: string
748
751
  ): void {
749
752
  if (meta) {
753
+ const encodedMeta = this.getUrlEncoded(meta);
750
754
  window.history.replaceState(
751
755
  {},
752
756
  "",
753
- `${parentReferencePath}?meta=${meta}`
757
+ `${parentReferencePath}?meta=${encodedMeta}`
754
758
  );
755
759
  }
756
760
  }
@@ -902,6 +906,18 @@ export default class AmfReference extends LightningElement {
902
906
  return meta;
903
907
  }
904
908
 
909
+ /**
910
+ * Gets the encoded url.
911
+ */
912
+ getUrlEncoded(url: string) {
913
+ // if url matches, then return the encoded url.
914
+ if (decodeURIComponent(url) === url) {
915
+ return encodeURIComponent(url);
916
+ }
917
+ // return the encoded url.
918
+ return this.getUrlEncoded(decodeURIComponent(url));
919
+ }
920
+
905
921
  /**
906
922
  *
907
923
  * @returns RouteMeta object for given referenceUrl
@@ -918,6 +934,10 @@ export default class AmfReference extends LightningElement {
918
934
  let type = "";
919
935
  if (this.isSpecBasedReference(referenceId)) {
920
936
  meta = this.getMetaFromUrl(referenceUrl);
937
+ // Always get the meta query param encoded and decode it and store it for internal use
938
+ // This has 2 advantages,
939
+ // 1. Supports backward compatible meta query param, so there is no need for redirects.
940
+ // 2. Supports Prerender and Coveo for their crawling.
921
941
  if (meta) {
922
942
  if (meta.includes(":")) {
923
943
  const metaInfo = meta.split(":");
@@ -1137,7 +1157,7 @@ export default class AmfReference extends LightningElement {
1137
1157
  }
1138
1158
  }
1139
1159
 
1140
- let isRedirecting = false
1160
+ let isRedirecting = false;
1141
1161
  if (referenceId) {
1142
1162
  const amfConfig = this.getAmfConfigWithId(referenceId);
1143
1163
  let redirectReferenceUrl = "";
@@ -1150,7 +1170,7 @@ export default class AmfReference extends LightningElement {
1150
1170
  if (redirectReferenceUrl) {
1151
1171
  if (this.isParentReferencePath(referenceUrl)) {
1152
1172
  // This is for CASE2 mentioned above, Where we need to navigate user to respective href
1153
- isRedirecting = true
1173
+ isRedirecting = true;
1154
1174
  window.location.href = redirectReferenceUrl;
1155
1175
  } else {
1156
1176
  // This is for CASE 1,3 and 4 mentioned above, Where we need to update the browser history
@@ -1206,16 +1226,18 @@ export default class AmfReference extends LightningElement {
1206
1226
  this.isSpecBasedReference(urlReferenceId);
1207
1227
  if (specBasedReference) {
1208
1228
  const metaVal = this.getMetaFromUrl(name);
1229
+ const encodedMeta = this.getUrlEncoded(metaVal);
1230
+ const decodedMeta = decodeURIComponent(encodedMeta);
1209
1231
  const currentSelectedMeta = this.selectedTopic
1210
1232
  ? this.selectedTopic.meta
1211
1233
  : "";
1212
1234
 
1213
- if (metaVal && metaVal === currentSelectedMeta) {
1235
+ if (decodedMeta && decodedMeta === currentSelectedMeta) {
1214
1236
  // selecting the same nav item, skip update
1215
1237
  return;
1216
1238
  }
1217
1239
 
1218
- const metadata = this.metadata[metaVal];
1240
+ const metadata = this.metadata[decodedMeta];
1219
1241
  if (metadata) {
1220
1242
  const {
1221
1243
  parentReferencePath,
@@ -1230,9 +1252,12 @@ export default class AmfReference extends LightningElement {
1230
1252
  amfId,
1231
1253
  type,
1232
1254
  elementId,
1233
- metaVal
1255
+ decodedMeta
1256
+ );
1257
+ this.updateUrlWithSelected(
1258
+ parentReferencePath,
1259
+ decodedMeta
1234
1260
  );
1235
- this.updateUrlWithSelected(parentReferencePath, metaVal);
1236
1261
  this.updateNavTitleMetaTag(metadata.navTitle);
1237
1262
  } else {
1238
1263
  if (this.isParentReferencePath(name)) {