@salesforcedevs/docs-components 0.56.2-seo-test10 → 0.56.2
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/LICENSE +12 -0
- package/package.json +2 -2
- package/src/modules/doc/amfReference/amfReference.html +5 -13
- package/src/modules/doc/amfReference/amfReference.ts +303 -767
- package/src/modules/doc/amfReference/route-meta.ts +22 -0
- package/src/modules/doc/amfReference/types.ts +3 -43
- package/src/modules/doc/contentLayout/contentLayout.ts +29 -74
- package/src/modules/doc/xmlContent/xmlContent.ts +16 -2
- package/src/modules/doc/amfReference/constants.ts +0 -76
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the URL reference meta on Reference page.
|
|
3
|
+
* Contains information on selected Reference ID, Topic ID, and Topic Type
|
|
4
|
+
* separated by ":"
|
|
5
|
+
*/
|
|
6
|
+
export class RouteMeta {
|
|
7
|
+
meta: string;
|
|
8
|
+
referenceId = "";
|
|
9
|
+
topicId = "";
|
|
10
|
+
type = "";
|
|
11
|
+
|
|
12
|
+
constructor(meta: string) {
|
|
13
|
+
this.meta = meta;
|
|
14
|
+
|
|
15
|
+
if (meta && meta.includes(":")) {
|
|
16
|
+
const [referenceId, type, topicId] = meta.split(":");
|
|
17
|
+
this.referenceId = referenceId;
|
|
18
|
+
this.topicId = topicId || type;
|
|
19
|
+
this.type = type;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -2,7 +2,6 @@ import { Json } from "typings/custom";
|
|
|
2
2
|
|
|
3
3
|
export interface AmfTopicType {
|
|
4
4
|
referenceId: string;
|
|
5
|
-
parentReferencePath: string;
|
|
6
5
|
amfId: string;
|
|
7
6
|
elementId: string;
|
|
8
7
|
type: string;
|
|
@@ -11,7 +10,6 @@ export interface AmfTopicType {
|
|
|
11
10
|
export interface AmfMetadataTopic extends AmfTopicType {
|
|
12
11
|
meta: string;
|
|
13
12
|
identifier: string;
|
|
14
|
-
navTitle?: string;
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export interface AmfMetaTopicType extends AmfTopicType {
|
|
@@ -55,37 +53,11 @@ export type DocPhaseEntry = {
|
|
|
55
53
|
body: string;
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Represents parsed topic for the sidebar.
|
|
62
|
-
*/
|
|
63
|
-
export interface ParsedMarkdownTopic {
|
|
64
|
-
label: string;
|
|
65
|
-
name: string;
|
|
66
|
-
children: ParsedMarkdownTopic[];
|
|
67
|
-
link?: {
|
|
68
|
-
href: string;
|
|
69
|
-
target?: string;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface AmfConfig {
|
|
56
|
+
export interface AmfConfig extends AmfModelRecord {
|
|
74
57
|
id: string;
|
|
58
|
+
amf: string;
|
|
75
59
|
version?: string;
|
|
76
60
|
docPhase?: DocPhaseEntry;
|
|
77
|
-
title: string;
|
|
78
|
-
href: string;
|
|
79
|
-
referenceType: ReferenceType;
|
|
80
|
-
|
|
81
|
-
// determines if a reference config is the current active and selected one.
|
|
82
|
-
isSelected: boolean;
|
|
83
|
-
|
|
84
|
-
// required for spec based references
|
|
85
|
-
amf?: string;
|
|
86
|
-
|
|
87
|
-
// required for markdown based references
|
|
88
|
-
topic?: ParsedMarkdownTopic;
|
|
89
61
|
}
|
|
90
62
|
|
|
91
63
|
export interface ParsedTopicModel {
|
|
@@ -112,22 +84,10 @@ export interface ReferenceVersion {
|
|
|
112
84
|
label: string;
|
|
113
85
|
deprecated?: boolean;
|
|
114
86
|
selected?: boolean;
|
|
115
|
-
link: {
|
|
116
|
-
href: string;
|
|
117
|
-
};
|
|
118
87
|
}
|
|
119
88
|
|
|
120
89
|
export interface ReferenceSetConfig {
|
|
121
|
-
refId?: string;
|
|
122
90
|
versionToRefMap?: Map<string, Array<AmfConfig>>;
|
|
123
91
|
refList: Array<AmfConfig>;
|
|
124
|
-
versions
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface RouteMeta {
|
|
128
|
-
meta: string;
|
|
129
|
-
referenceId: string;
|
|
130
|
-
topicId: string;
|
|
131
|
-
//type is only for spec based references
|
|
132
|
-
type?: string;
|
|
92
|
+
versions?: Array<ReferenceVersion>;
|
|
133
93
|
}
|
|
@@ -20,7 +20,6 @@ const HIGHLIGHTABLE_SELECTOR = [
|
|
|
20
20
|
"th",
|
|
21
21
|
"td"
|
|
22
22
|
].join(",");
|
|
23
|
-
const OBSERVER_ATTACH_WAIT_TIME = 500;
|
|
24
23
|
|
|
25
24
|
export default class ContentLayout extends LightningElement {
|
|
26
25
|
@api sidebarValue: string;
|
|
@@ -96,8 +95,6 @@ export default class ContentLayout extends LightningElement {
|
|
|
96
95
|
target: window
|
|
97
96
|
});
|
|
98
97
|
private tocValue?: string = undefined;
|
|
99
|
-
private observerTimerId = null;
|
|
100
|
-
private didScrollToSelectedHash = false;
|
|
101
98
|
|
|
102
99
|
get showToc(): boolean {
|
|
103
100
|
return this.tocOptions && this.tocOptions.length > 0;
|
|
@@ -122,18 +119,6 @@ export default class ContentLayout extends LightningElement {
|
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
121
|
|
|
125
|
-
renderedCallback(): void {
|
|
126
|
-
/**
|
|
127
|
-
* Note: We are adding timeout because chrome is optimizing and not triggering recent renderedCallback though elements reference is changed
|
|
128
|
-
* Also we are considering recent renderedCallback
|
|
129
|
-
*/
|
|
130
|
-
this.clearRenderObserverTimer();
|
|
131
|
-
this.observerTimerId = setTimeout(
|
|
132
|
-
this.attachInteractionObserver,
|
|
133
|
-
OBSERVER_ATTACH_WAIT_TIME
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
122
|
disconnectedCallback(): void {
|
|
138
123
|
this.disconnectObserver();
|
|
139
124
|
window.removeEventListener(
|
|
@@ -141,25 +126,19 @@ export default class ContentLayout extends LightningElement {
|
|
|
141
126
|
this.updateHighlighted
|
|
142
127
|
);
|
|
143
128
|
this.searchSyncer.dispose();
|
|
144
|
-
this.clearRenderObserverTimer();
|
|
145
129
|
}
|
|
146
130
|
|
|
147
|
-
clearRenderObserverTimer = () => {
|
|
148
|
-
if (this.observerTimerId) {
|
|
149
|
-
clearTimeout(this.observerTimerId);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
131
|
updateHighlighted = (event: Event): void =>
|
|
154
132
|
highlightTerms(
|
|
155
133
|
this.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
|
|
156
134
|
(event as CustomEvent<string>).detail
|
|
157
135
|
);
|
|
158
136
|
|
|
159
|
-
|
|
137
|
+
onSlotChange(event: Event): void {
|
|
160
138
|
if (!this.enableSlotChange) {
|
|
161
139
|
return;
|
|
162
140
|
}
|
|
141
|
+
|
|
163
142
|
this.disconnectObserver();
|
|
164
143
|
this.observer = new IntersectionObserver((entries) => {
|
|
165
144
|
entries.forEach(
|
|
@@ -171,54 +150,30 @@ export default class ContentLayout extends LightningElement {
|
|
|
171
150
|
this.calculateActualSection();
|
|
172
151
|
});
|
|
173
152
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
153
|
+
const anchoredTags = (event.target as HTMLSlotElement)
|
|
154
|
+
.assignedElements()
|
|
155
|
+
.filter(({ tagName }) => tagName === TOC_HEADER_TAG)
|
|
156
|
+
.map((tag) => {
|
|
157
|
+
tag.id = tag.hash;
|
|
158
|
+
return tag;
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
this._tocOptions = anchoredTags.map((tag) => ({
|
|
162
|
+
anchor: `#${tag.hash}`,
|
|
163
|
+
id: tag.id,
|
|
164
|
+
label: tag.title
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
this.scrollToHash(anchoredTags);
|
|
168
|
+
|
|
169
|
+
anchoredTags.forEach((section) => {
|
|
170
|
+
const id = section.getAttribute("id");
|
|
179
171
|
this.anchoredElements[id] = {
|
|
180
172
|
id,
|
|
181
173
|
intersect: false
|
|
182
174
|
};
|
|
183
|
-
this.observer.observe(
|
|
184
|
-
}
|
|
185
|
-
if (!this.didScrollToSelectedHash) {
|
|
186
|
-
this.didScrollToSelectedHash = true;
|
|
187
|
-
this.scrollToHash(headingElements);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
onSlotChange(event: Event): void {
|
|
192
|
-
const slotElements = (
|
|
193
|
-
event.target as HTMLSlotElement
|
|
194
|
-
).assignedElements();
|
|
195
|
-
|
|
196
|
-
if (slotElements.length) {
|
|
197
|
-
const slotContentElement = slotElements[0];
|
|
198
|
-
const headingElements =
|
|
199
|
-
slotContentElement.ownerDocument?.getElementsByTagName(
|
|
200
|
-
TOC_HEADER_TAG
|
|
201
|
-
);
|
|
202
|
-
for (const headingElement of headingElements) {
|
|
203
|
-
// Sometimes elements hash is not being set when slot content is wrapped with div
|
|
204
|
-
headingElement.hash =
|
|
205
|
-
headingElement.attributes.hash?.nodeValue;
|
|
206
|
-
}
|
|
207
|
-
const tocOptions = [];
|
|
208
|
-
for (const headingElement of headingElements) {
|
|
209
|
-
headingElement.id = headingElement.hash;
|
|
210
|
-
|
|
211
|
-
// Update tocOptions from anchorTags
|
|
212
|
-
const tocItem = {
|
|
213
|
-
anchor: `#${headingElement.hash}`,
|
|
214
|
-
id: headingElement.id,
|
|
215
|
-
label: headingElement.title
|
|
216
|
-
};
|
|
217
|
-
tocOptions.push(tocItem);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
this._tocOptions = tocOptions;
|
|
221
|
-
}
|
|
175
|
+
this.observer.observe(section);
|
|
176
|
+
});
|
|
222
177
|
}
|
|
223
178
|
|
|
224
179
|
private disconnectObserver(): void {
|
|
@@ -228,16 +183,16 @@ export default class ContentLayout extends LightningElement {
|
|
|
228
183
|
}
|
|
229
184
|
}
|
|
230
185
|
|
|
231
|
-
|
|
232
|
-
private scrollToHash(headingElements: NodeListOf<Element>): void {
|
|
186
|
+
private scrollToHash(anchoredTags: Array<Element>): void {
|
|
233
187
|
let { hash } = window.location;
|
|
188
|
+
|
|
234
189
|
if (hash) {
|
|
235
190
|
hash = hash.substr(1);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
191
|
+
const toScrollElement = anchoredTags.find(
|
|
192
|
+
(element) => element.getAttribute("id") === hash
|
|
193
|
+
);
|
|
194
|
+
if (toScrollElement) {
|
|
195
|
+
toScrollElement.scrollIntoView({ behavior: "auto" });
|
|
241
196
|
}
|
|
242
197
|
}
|
|
243
198
|
}
|
|
@@ -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
|
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
const NAVIGATION_ITEMS = [
|
|
2
|
-
{
|
|
3
|
-
label: "Summary",
|
|
4
|
-
name: "summary",
|
|
5
|
-
childrenPropertyName: undefined,
|
|
6
|
-
type: "summary"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
label: "Endpoints",
|
|
10
|
-
name: "endpoints",
|
|
11
|
-
childrenPropertyName: "endpoints",
|
|
12
|
-
type: "endpoint"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
label: "Documentation",
|
|
16
|
-
name: "documentation",
|
|
17
|
-
childrenPropertyName: "docs",
|
|
18
|
-
type: "documentation"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
label: "Types",
|
|
22
|
-
name: "types",
|
|
23
|
-
childrenPropertyName: "types",
|
|
24
|
-
type: "type"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
label: "Security",
|
|
28
|
-
name: "security",
|
|
29
|
-
childrenPropertyName: "security",
|
|
30
|
-
type: "security"
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const URL_CONFIG = {
|
|
35
|
-
summary: {
|
|
36
|
-
urlIdentifer: "label"
|
|
37
|
-
},
|
|
38
|
-
endpoint: {
|
|
39
|
-
urlIdentifer: "path"
|
|
40
|
-
},
|
|
41
|
-
method: {
|
|
42
|
-
urlIdentifer: "label"
|
|
43
|
-
},
|
|
44
|
-
documentation: {
|
|
45
|
-
urlIdentifer: "label"
|
|
46
|
-
},
|
|
47
|
-
type: {
|
|
48
|
-
urlIdentifer: "label",
|
|
49
|
-
prefix: "type:"
|
|
50
|
-
},
|
|
51
|
-
security: {
|
|
52
|
-
urlIdentifer: "label",
|
|
53
|
-
prefix: "security:"
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const REFERENCE_TYPES = {
|
|
58
|
-
markdown: "markdown",
|
|
59
|
-
raml: "rest-raml",
|
|
60
|
-
oa2: "rest-oa2",
|
|
61
|
-
oa3: "rest-oa3"
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const oldReferenceIdNewReferenceIdMap: Record<string, string> = {
|
|
65
|
-
"commerce-api-assignments": "assignments",
|
|
66
|
-
"commerce-api-campaigns": "campaigns",
|
|
67
|
-
"commerce-api-catalogs": "catalogs",
|
|
68
|
-
"cdn-zones": "cdn-api-process-apis",
|
|
69
|
-
"inventory-impex": "impex",
|
|
70
|
-
"inventory-reservations": "inventory-reservation-service",
|
|
71
|
-
"shopper-login-and-api-access-service": "shopper-login",
|
|
72
|
-
"shopper-login-and-api-access-service-admin": "slas-admin",
|
|
73
|
-
"einstein-recommendations": "einstein-api-quick-start-guide"
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export { NAVIGATION_ITEMS, URL_CONFIG, oldReferenceIdNewReferenceIdMap };
|