@salesforcedevs/docs-components 0.56.2-seo-test4 → 0.56.2-seo-test7
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
|
@@ -3,6 +3,7 @@ import { noCase } from "no-case";
|
|
|
3
3
|
import { sentenceCase } from "sentence-case";
|
|
4
4
|
import qs from "query-string";
|
|
5
5
|
import { AmfModelParser } from "./utils";
|
|
6
|
+
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
6
7
|
import type {
|
|
7
8
|
AmfConfig,
|
|
8
9
|
AmfMetadataTopic,
|
|
@@ -37,7 +38,6 @@ export default class AmfReference extends LightningElement {
|
|
|
37
38
|
@api tocOptions?: string;
|
|
38
39
|
@track navigation = [];
|
|
39
40
|
@track versions: Array<ReferenceVersion> = [];
|
|
40
|
-
@api expandChildren?: boolean = false;
|
|
41
41
|
|
|
42
42
|
// Update this to update what component gets rendered in the content block
|
|
43
43
|
@track
|
|
@@ -124,6 +124,15 @@ export default class AmfReference extends LightningElement {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
@api
|
|
128
|
+
get expandChildren() {
|
|
129
|
+
return this._expandChildren;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
set expandChildren(value) {
|
|
133
|
+
this._expandChildren = normalizeBoolean(value);
|
|
134
|
+
}
|
|
135
|
+
|
|
127
136
|
// model
|
|
128
137
|
protected _amfConfigList: AmfConfig[] = [];
|
|
129
138
|
protected _amfConfigMap: Map<string, AmfConfig> = new Map();
|
|
@@ -143,6 +152,7 @@ export default class AmfReference extends LightningElement {
|
|
|
143
152
|
|
|
144
153
|
private isParentLevelDocPhaseEnabled = false;
|
|
145
154
|
private selectedReferenceDocPhase?: string | null = null;
|
|
155
|
+
private _expandChildren?: boolean = false;
|
|
146
156
|
|
|
147
157
|
/**
|
|
148
158
|
* Key for storing the currently selected reference url. This will be used to save the
|
|
@@ -441,11 +451,14 @@ export default class AmfReference extends LightningElement {
|
|
|
441
451
|
|
|
442
452
|
items.forEach((item) => {
|
|
443
453
|
item.methods?.forEach((method) => {
|
|
454
|
+
const title =
|
|
455
|
+
this.getTitleForLabel(method.label) || method.method;
|
|
444
456
|
const meta = this.addToMetadata(
|
|
445
457
|
parentReferencePath,
|
|
446
458
|
referenceId,
|
|
447
459
|
"method",
|
|
448
|
-
method
|
|
460
|
+
method,
|
|
461
|
+
title
|
|
449
462
|
);
|
|
450
463
|
methodList.push(
|
|
451
464
|
Object.assign(method, {
|
|
@@ -453,8 +466,7 @@ export default class AmfReference extends LightningElement {
|
|
|
453
466
|
parentReferencePath,
|
|
454
467
|
meta
|
|
455
468
|
),
|
|
456
|
-
label:
|
|
457
|
-
this.getTitleForLabel(method.label) || method.method
|
|
469
|
+
label: title
|
|
458
470
|
})
|
|
459
471
|
);
|
|
460
472
|
});
|
|
@@ -499,7 +511,8 @@ export default class AmfReference extends LightningElement {
|
|
|
499
511
|
parentReferencePath,
|
|
500
512
|
referenceId,
|
|
501
513
|
type,
|
|
502
|
-
summary
|
|
514
|
+
summary,
|
|
515
|
+
label
|
|
503
516
|
);
|
|
504
517
|
children.push({
|
|
505
518
|
label,
|
|
@@ -572,7 +585,8 @@ export default class AmfReference extends LightningElement {
|
|
|
572
585
|
parentReferencePath,
|
|
573
586
|
referenceId,
|
|
574
587
|
type,
|
|
575
|
-
topic
|
|
588
|
+
topic,
|
|
589
|
+
topic.label
|
|
576
590
|
);
|
|
577
591
|
return {
|
|
578
592
|
label: topic.label,
|
|
@@ -601,7 +615,8 @@ export default class AmfReference extends LightningElement {
|
|
|
601
615
|
parentReferencePath: string,
|
|
602
616
|
referenceId: string,
|
|
603
617
|
type: string,
|
|
604
|
-
topic: { id: string; domId: string }
|
|
618
|
+
topic: { id: string; domId: string },
|
|
619
|
+
navTitle: string
|
|
605
620
|
): string | undefined {
|
|
606
621
|
const { urlIdentifer, prefix } = URL_CONFIG[type];
|
|
607
622
|
|
|
@@ -619,7 +634,8 @@ export default class AmfReference extends LightningElement {
|
|
|
619
634
|
amfId: topic.id,
|
|
620
635
|
elementId: topic.domId,
|
|
621
636
|
identifier,
|
|
622
|
-
type
|
|
637
|
+
type,
|
|
638
|
+
navTitle
|
|
623
639
|
};
|
|
624
640
|
}
|
|
625
641
|
return meta;
|
|
@@ -925,46 +941,56 @@ export default class AmfReference extends LightningElement {
|
|
|
925
941
|
}
|
|
926
942
|
|
|
927
943
|
/**
|
|
928
|
-
* Finds and returns referenceUrl if given topic url matches
|
|
944
|
+
* Finds and returns referenceUrl and topicTitle if given topic url matches
|
|
929
945
|
*/
|
|
930
|
-
|
|
946
|
+
getReferenceDetailsInGivenTopics(
|
|
931
947
|
topics: ParsedMarkdownTopic[],
|
|
932
948
|
topicMeta: string
|
|
933
|
-
): string {
|
|
949
|
+
): { referenceUrl: string; topicTitle: string } {
|
|
934
950
|
let referenceUrl = "";
|
|
951
|
+
let topicTitle = "";
|
|
935
952
|
for (let i = 0; i < topics.length; i++) {
|
|
936
953
|
const topic = topics[i];
|
|
937
954
|
const meta = this.getMarkdownReferenceMeta(topic.link.href);
|
|
938
955
|
const childTopics = topic.children;
|
|
939
956
|
if (meta === topicMeta) {
|
|
940
957
|
referenceUrl = topic.link.href;
|
|
958
|
+
topicTitle = topic.label;
|
|
941
959
|
} else if (childTopics && childTopics.length) {
|
|
942
|
-
|
|
960
|
+
const referenceDetails = this.getReferenceDetailsInGivenTopics(
|
|
943
961
|
childTopics,
|
|
944
962
|
topicMeta
|
|
945
963
|
);
|
|
964
|
+
referenceUrl = referenceDetails.referenceUrl;
|
|
965
|
+
topicTitle = referenceDetails.topicTitle;
|
|
946
966
|
}
|
|
947
|
-
if (referenceUrl) {
|
|
967
|
+
if (referenceUrl && topicTitle) {
|
|
948
968
|
break;
|
|
949
969
|
}
|
|
950
970
|
}
|
|
951
|
-
return
|
|
971
|
+
return {
|
|
972
|
+
referenceUrl,
|
|
973
|
+
topicTitle
|
|
974
|
+
};
|
|
952
975
|
}
|
|
953
976
|
|
|
954
977
|
/**
|
|
955
|
-
* Gives referenceUrl for given markdown topic url
|
|
978
|
+
* Gives referenceUrl and topicTitle for given markdown topic url
|
|
956
979
|
*/
|
|
957
|
-
|
|
980
|
+
getRefDetailsForGivenTopicMeta(
|
|
958
981
|
referenceId: string,
|
|
959
982
|
topicMeta: string
|
|
960
|
-
): string | undefined {
|
|
983
|
+
): { referenceUrl: string; topicTitle: string } | undefined {
|
|
961
984
|
const amfConfig = this.getAmfConfigWithId(referenceId);
|
|
962
|
-
let
|
|
985
|
+
let referenceDetails;
|
|
963
986
|
if (amfConfig) {
|
|
964
987
|
const topics = amfConfig.topic?.children || [];
|
|
965
|
-
|
|
988
|
+
referenceDetails = this.getReferenceDetailsInGivenTopics(
|
|
989
|
+
topics,
|
|
990
|
+
topicMeta
|
|
991
|
+
);
|
|
966
992
|
}
|
|
967
|
-
return
|
|
993
|
+
return referenceDetails;
|
|
968
994
|
}
|
|
969
995
|
|
|
970
996
|
/**
|
|
@@ -1020,6 +1046,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1020
1046
|
referenceId,
|
|
1021
1047
|
"summary"
|
|
1022
1048
|
);
|
|
1049
|
+
this.updateNavTitleMetaTag(selectedItemMetaData.navTitle);
|
|
1023
1050
|
}
|
|
1024
1051
|
|
|
1025
1052
|
if (selectedItemMetaData) {
|
|
@@ -1035,19 +1062,33 @@ export default class AmfReference extends LightningElement {
|
|
|
1035
1062
|
selectedItemMetaData.parentReferencePath,
|
|
1036
1063
|
selectedItemMetaData.meta
|
|
1037
1064
|
);
|
|
1065
|
+
this.updateNavTitleMetaTag(selectedItemMetaData.navTitle);
|
|
1038
1066
|
}
|
|
1039
1067
|
});
|
|
1040
1068
|
} else {
|
|
1041
1069
|
let invalidTopicReferenceUrl = "";
|
|
1042
1070
|
if (topicId) {
|
|
1043
|
-
const
|
|
1071
|
+
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1044
1072
|
referenceId,
|
|
1045
1073
|
topicId
|
|
1046
1074
|
);
|
|
1075
|
+
const selectedItemUrl = referenceDetails?.referenceUrl;
|
|
1047
1076
|
if (!selectedItemUrl) {
|
|
1048
1077
|
invalidTopicReferenceUrl = previousRefUrlInSession;
|
|
1049
1078
|
}
|
|
1050
1079
|
}
|
|
1080
|
+
if (!invalidTopicReferenceUrl) {
|
|
1081
|
+
const referenceUrl = window.location.href;
|
|
1082
|
+
const referenceMeta =
|
|
1083
|
+
this.getMarkdownReferenceMeta(referenceUrl);
|
|
1084
|
+
const selectedItemRefId =
|
|
1085
|
+
this.getReferenceIdFromUrl(referenceUrl);
|
|
1086
|
+
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1087
|
+
selectedItemRefId,
|
|
1088
|
+
referenceMeta
|
|
1089
|
+
);
|
|
1090
|
+
this.updateNavTitleMetaTag(referenceDetails.topicTitle);
|
|
1091
|
+
}
|
|
1051
1092
|
this.loadMarkdownBasedReference(invalidTopicReferenceUrl);
|
|
1052
1093
|
}
|
|
1053
1094
|
}
|
|
@@ -1099,10 +1140,11 @@ export default class AmfReference extends LightningElement {
|
|
|
1099
1140
|
*/
|
|
1100
1141
|
const referenceMeta = this.getMarkdownReferenceMeta(referenceUrl);
|
|
1101
1142
|
const selectedItemRefId = this.getReferenceIdFromUrl(referenceUrl);
|
|
1102
|
-
const
|
|
1143
|
+
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1103
1144
|
selectedItemRefId,
|
|
1104
1145
|
referenceMeta
|
|
1105
1146
|
);
|
|
1147
|
+
const selectedItemUrl = referenceDetails?.referenceUrl;
|
|
1106
1148
|
if (!selectedItemUrl) {
|
|
1107
1149
|
referenceId = this.getReferenceIdFromUrl(referenceUrl);
|
|
1108
1150
|
}
|
|
@@ -1145,6 +1187,15 @@ export default class AmfReference extends LightningElement {
|
|
|
1145
1187
|
);
|
|
1146
1188
|
}
|
|
1147
1189
|
|
|
1190
|
+
private updateNavTitleMetaTag(navTitle = ""): void {
|
|
1191
|
+
// this is required to update the nav title meta tag.
|
|
1192
|
+
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
1193
|
+
const metaNavTitle = document.querySelector('meta[name="nav-title"]');
|
|
1194
|
+
if (metaNavTitle && navTitle) {
|
|
1195
|
+
metaNavTitle.setAttribute("content", navTitle);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1148
1199
|
onNavSelect(event: CustomEvent): void {
|
|
1149
1200
|
const name = event.detail.name;
|
|
1150
1201
|
if (name) {
|
|
@@ -1180,6 +1231,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1180
1231
|
metaVal
|
|
1181
1232
|
);
|
|
1182
1233
|
this.updateUrlWithSelected(parentReferencePath, metaVal);
|
|
1234
|
+
this.updateNavTitleMetaTag(metadata.navTitle);
|
|
1183
1235
|
} else {
|
|
1184
1236
|
if (this.isParentReferencePath(name)) {
|
|
1185
1237
|
this.loadNewReferenceItem(name);
|