@salesforcedevs/docs-components 0.56.2-seo-test9 → 0.56.2-seo-test12
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
|
@@ -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=${
|
|
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
|
-
|
|
485
|
+
const encodedMeta = meta ? this.getUrlEncoded(meta) : "";
|
|
486
|
+
return encodedMeta ? `${parentReferencePath}?meta=${encodedMeta}` : "";
|
|
485
487
|
}
|
|
486
488
|
|
|
487
489
|
/**
|
|
@@ -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=${
|
|
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=${
|
|
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(":");
|
|
@@ -1076,18 +1096,6 @@ export default class AmfReference extends LightningElement {
|
|
|
1076
1096
|
invalidTopicReferenceUrl = previousRefUrlInSession;
|
|
1077
1097
|
}
|
|
1078
1098
|
}
|
|
1079
|
-
if (!invalidTopicReferenceUrl) {
|
|
1080
|
-
const referenceUrl = window.location.href;
|
|
1081
|
-
const referenceMeta =
|
|
1082
|
-
this.getMarkdownReferenceMeta(referenceUrl);
|
|
1083
|
-
const selectedItemRefId =
|
|
1084
|
-
this.getReferenceIdFromUrl(referenceUrl);
|
|
1085
|
-
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1086
|
-
selectedItemRefId,
|
|
1087
|
-
referenceMeta
|
|
1088
|
-
);
|
|
1089
|
-
this.updateNavTitleMetaTag(referenceDetails.topicTitle);
|
|
1090
|
-
}
|
|
1091
1099
|
this.loadMarkdownBasedReference(invalidTopicReferenceUrl);
|
|
1092
1100
|
}
|
|
1093
1101
|
}
|
|
@@ -1149,6 +1157,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1149
1157
|
}
|
|
1150
1158
|
}
|
|
1151
1159
|
|
|
1160
|
+
let isRedirecting = false;
|
|
1152
1161
|
if (referenceId) {
|
|
1153
1162
|
const amfConfig = this.getAmfConfigWithId(referenceId);
|
|
1154
1163
|
let redirectReferenceUrl = "";
|
|
@@ -1161,6 +1170,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1161
1170
|
if (redirectReferenceUrl) {
|
|
1162
1171
|
if (this.isParentReferencePath(referenceUrl)) {
|
|
1163
1172
|
// This is for CASE2 mentioned above, Where we need to navigate user to respective href
|
|
1173
|
+
isRedirecting = true;
|
|
1164
1174
|
window.location.href = redirectReferenceUrl;
|
|
1165
1175
|
} else {
|
|
1166
1176
|
// This is for CASE 1,3 and 4 mentioned above, Where we need to update the browser history
|
|
@@ -1168,11 +1178,24 @@ export default class AmfReference extends LightningElement {
|
|
|
1168
1178
|
}
|
|
1169
1179
|
}
|
|
1170
1180
|
}
|
|
1181
|
+
if (!isRedirecting) {
|
|
1182
|
+
const currentReferenceUrl = window.location.href;
|
|
1183
|
+
const referenceMeta =
|
|
1184
|
+
this.getMarkdownReferenceMeta(currentReferenceUrl);
|
|
1185
|
+
const selectedItemRefId =
|
|
1186
|
+
this.getReferenceIdFromUrl(currentReferenceUrl);
|
|
1187
|
+
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1188
|
+
selectedItemRefId,
|
|
1189
|
+
referenceMeta
|
|
1190
|
+
);
|
|
1191
|
+
if (referenceDetails) {
|
|
1192
|
+
this.updateNavTitleMetaTag(referenceDetails.topicTitle);
|
|
1193
|
+
}
|
|
1171
1194
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1195
|
+
this.versions = this.getVersions();
|
|
1196
|
+
this.updateDocPhase();
|
|
1197
|
+
this.selectedSidebarValue = window.location.pathname;
|
|
1198
|
+
}
|
|
1176
1199
|
}
|
|
1177
1200
|
|
|
1178
1201
|
/**
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
14
14
|
import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
|
|
15
15
|
import { Language } from "typings/custom";
|
|
16
|
-
import { DEFAULT_LANGUAGES } from "dxUtils/constants";
|
|
17
16
|
|
|
18
17
|
// TODO: Imitating from actual implementation as doc-content use it like this. We should refactor it later.
|
|
19
18
|
const handleContentError = (error): void => console.log(error);
|
|
@@ -100,7 +99,7 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
100
99
|
shouldStopPropagation: true,
|
|
101
100
|
target: window
|
|
102
101
|
});
|
|
103
|
-
private _allLanguages: Array<Language> =
|
|
102
|
+
private _allLanguages: Array<Language> = [];
|
|
104
103
|
|
|
105
104
|
@track private pageReference: PageReference = {};
|
|
106
105
|
|
|
@@ -584,5 +583,20 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
584
583
|
metadescription.setAttribute("content", docDescription);
|
|
585
584
|
}
|
|
586
585
|
}
|
|
586
|
+
|
|
587
|
+
if (this.pageReference) {
|
|
588
|
+
const metadescription = document.querySelector(
|
|
589
|
+
'link[rel="canonical"]'
|
|
590
|
+
);
|
|
591
|
+
if (metadescription) {
|
|
592
|
+
metadescription.setAttribute(
|
|
593
|
+
"href",
|
|
594
|
+
window.location.protocol +
|
|
595
|
+
"//" +
|
|
596
|
+
window.location.host +
|
|
597
|
+
this.pageReferenceToString(this.pageReference)
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
}
|
|
587
601
|
}
|
|
588
602
|
}
|