@salesforcedevs/dw-components 1.20.16-ssg-alpha → 1.20.16-ssg-alpha2
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,5 +1,5 @@
|
|
|
1
1
|
import { api, LightningElement } from "lwc";
|
|
2
|
-
import { toJson } from "dxUtils/normalizers";
|
|
2
|
+
import { normalizeBoolean, toJson } from "dxUtils/normalizers";
|
|
3
3
|
import { DocsTile, DropdownItem, Language } from "typings/custom";
|
|
4
4
|
import qs from "query-string";
|
|
5
5
|
import uniqBy from "lodash.uniqby";
|
|
@@ -58,12 +58,13 @@ export default class DocsGrid extends LightningElement {
|
|
|
58
58
|
private _allLanguages: Array<Language> = [];
|
|
59
59
|
private filteredItemsSelected: boolean = false;
|
|
60
60
|
private _isFetchingOtherDocs: boolean = false;
|
|
61
|
+
private _ssgEnabled: boolean = false;
|
|
61
62
|
|
|
62
63
|
connectedCallback(): void {
|
|
63
64
|
this.retrieveDscApis(true);
|
|
64
65
|
|
|
65
|
-
// If SSG_ENABLED is true
|
|
66
|
-
if (
|
|
66
|
+
// If SSG_ENABLED is true, fetch from /sitemetadata
|
|
67
|
+
if (this.ssgEnabled) {
|
|
67
68
|
this.fetchOtherDocsFromSitemetadata();
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -104,6 +105,17 @@ export default class DocsGrid extends LightningElement {
|
|
|
104
105
|
|
|
105
106
|
@api apiDomain = "https://developer.salesforce.com";
|
|
106
107
|
|
|
108
|
+
@api
|
|
109
|
+
get ssgEnabled(): boolean {
|
|
110
|
+
return this._ssgEnabled;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
set ssgEnabled(value) {
|
|
114
|
+
if (value) {
|
|
115
|
+
this._ssgEnabled = normalizeBoolean(value);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
107
119
|
@api
|
|
108
120
|
get externalMicrosites() {
|
|
109
121
|
return this._externalMicrosites || [];
|
|
@@ -128,23 +140,18 @@ export default class DocsGrid extends LightningElement {
|
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
set otherDocs(value: any) {
|
|
131
|
-
|
|
132
|
-
if (!this._isFetchingOtherDocs) {
|
|
133
|
-
this.fetchOtherDocsFromSitemetadata();
|
|
134
|
-
} else {
|
|
135
|
-
this.processOtherDocs(value);
|
|
136
|
-
}
|
|
143
|
+
this._otherDocs = this.transformOtherDocs(value);
|
|
137
144
|
}
|
|
138
145
|
|
|
139
|
-
private
|
|
146
|
+
private transformOtherDocs(value: any): any[] {
|
|
140
147
|
const allDocs = toJson(value);
|
|
141
|
-
|
|
148
|
+
const transformed: any[] = [];
|
|
142
149
|
|
|
143
150
|
for (const docs of allDocs) {
|
|
144
151
|
for (const project of docs.projects) {
|
|
145
152
|
const firstLink = project.contentTypes[0].href;
|
|
146
153
|
|
|
147
|
-
|
|
154
|
+
transformed.push({
|
|
148
155
|
id: project.id,
|
|
149
156
|
title: project.title,
|
|
150
157
|
description: project.description,
|
|
@@ -155,6 +162,8 @@ export default class DocsGrid extends LightningElement {
|
|
|
155
162
|
});
|
|
156
163
|
}
|
|
157
164
|
}
|
|
165
|
+
|
|
166
|
+
return transformed;
|
|
158
167
|
}
|
|
159
168
|
|
|
160
169
|
async fetchOtherDocsFromSitemetadata(): Promise<void> {
|
|
@@ -168,7 +177,7 @@ export default class DocsGrid extends LightningElement {
|
|
|
168
177
|
|
|
169
178
|
if (response.ok) {
|
|
170
179
|
const data = await response.json();
|
|
171
|
-
this.
|
|
180
|
+
this._otherDocs = this.transformOtherDocs(data);
|
|
172
181
|
} else {
|
|
173
182
|
console.error(
|
|
174
183
|
`Failed to fetch sitemetadata: ${response.status}`
|