@salesforcedevs/docs-components 0.56.2-seo-test3 → 0.56.2-seo-test6
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
|
+
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,15 +1062,17 @@ 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
|
}
|
|
@@ -1073,6 +1102,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1073
1102
|
|
|
1074
1103
|
private loadMarkdownBasedReference(referenceUrl?: string): void {
|
|
1075
1104
|
let referenceId = "";
|
|
1105
|
+
let topicTitle;
|
|
1076
1106
|
const currentUrl = window.location.href;
|
|
1077
1107
|
if (this.isProjectRootPath()) {
|
|
1078
1108
|
/**
|
|
@@ -1099,10 +1129,12 @@ export default class AmfReference extends LightningElement {
|
|
|
1099
1129
|
*/
|
|
1100
1130
|
const referenceMeta = this.getMarkdownReferenceMeta(referenceUrl);
|
|
1101
1131
|
const selectedItemRefId = this.getReferenceIdFromUrl(referenceUrl);
|
|
1102
|
-
const
|
|
1132
|
+
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1103
1133
|
selectedItemRefId,
|
|
1104
1134
|
referenceMeta
|
|
1105
1135
|
);
|
|
1136
|
+
const selectedItemUrl = referenceDetails?.referenceUrl;
|
|
1137
|
+
topicTitle = referenceDetails?.topicTitle;
|
|
1106
1138
|
if (!selectedItemUrl) {
|
|
1107
1139
|
referenceId = this.getReferenceIdFromUrl(referenceUrl);
|
|
1108
1140
|
}
|
|
@@ -1115,6 +1147,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1115
1147
|
const childrenItems = amfConfig.topic.children;
|
|
1116
1148
|
if (childrenItems.length > 0) {
|
|
1117
1149
|
redirectReferenceUrl = childrenItems[0].link.href;
|
|
1150
|
+
topicTitle = childrenItems[0].label;
|
|
1118
1151
|
}
|
|
1119
1152
|
}
|
|
1120
1153
|
if (redirectReferenceUrl) {
|
|
@@ -1128,6 +1161,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1128
1161
|
}
|
|
1129
1162
|
}
|
|
1130
1163
|
|
|
1164
|
+
this.updateNavTitleMetaTag(topicTitle);
|
|
1131
1165
|
this.versions = this.getVersions();
|
|
1132
1166
|
|
|
1133
1167
|
this.updateDocPhase();
|
|
@@ -1145,6 +1179,15 @@ export default class AmfReference extends LightningElement {
|
|
|
1145
1179
|
);
|
|
1146
1180
|
}
|
|
1147
1181
|
|
|
1182
|
+
private updateNavTitleMetaTag(navTitle = ""): void {
|
|
1183
|
+
// this is required to update the nav title meta tag.
|
|
1184
|
+
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
1185
|
+
const metaNavTitle = document.querySelector('meta[name="nav-title"]');
|
|
1186
|
+
if (metaNavTitle && navTitle) {
|
|
1187
|
+
metaNavTitle.setAttribute("content", navTitle);
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1148
1191
|
onNavSelect(event: CustomEvent): void {
|
|
1149
1192
|
const name = event.detail.name;
|
|
1150
1193
|
if (name) {
|
|
@@ -1180,6 +1223,7 @@ export default class AmfReference extends LightningElement {
|
|
|
1180
1223
|
metaVal
|
|
1181
1224
|
);
|
|
1182
1225
|
this.updateUrlWithSelected(parentReferencePath, metaVal);
|
|
1226
|
+
this.updateNavTitleMetaTag(metadata.navTitle);
|
|
1183
1227
|
} else {
|
|
1184
1228
|
if (this.isParentReferencePath(name)) {
|
|
1185
1229
|
this.loadNewReferenceItem(name);
|