@quintype/framework 7.18.0 → 7.18.1-test-ga.0
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/client/start.js +46 -34
- package/package.json +1 -1
package/client/start.js
CHANGED
|
@@ -55,20 +55,20 @@ function getRouteData(path, { location = global.location, existingFetch, mountAt
|
|
|
55
55
|
const [routeDataPath, relativePath] = getRouteDataAndPath(path, mountAt);
|
|
56
56
|
const url = new URL(relativePath, location.origin);
|
|
57
57
|
return (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
existingFetch ||
|
|
59
|
+
fetch(`${routeDataPath}?path=${encodeURIComponent(url.pathname)}${url.search ? `&${url.search.slice(1)}` : ""}`, {
|
|
60
|
+
credentials: "same-origin",
|
|
61
|
+
})
|
|
62
62
|
)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
.then((response) => {
|
|
64
|
+
if (response.status == 404) {
|
|
65
|
+
// There is a chance this might abort
|
|
66
|
+
maybeBypassServiceWorker();
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
return response.json();
|
|
70
|
+
})
|
|
71
|
+
.then(maybeRedirect);
|
|
72
72
|
|
|
73
73
|
function maybeRedirect(page) {
|
|
74
74
|
// This next line aborts the entire load
|
|
@@ -123,7 +123,7 @@ export function navigateToPage(dispatch, path, doNotPushPath) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
Promise.resolve(
|
|
126
|
-
|
|
126
|
+
pickComponentWrapper && pickComponentWrapper.preloadComponent(page.pageType, page.subPageType)
|
|
127
127
|
).then(() => {
|
|
128
128
|
dispatch({
|
|
129
129
|
type: NAVIGATE_TO_PAGE,
|
|
@@ -132,6 +132,16 @@ export function navigateToPage(dispatch, path, doNotPushPath) {
|
|
|
132
132
|
});
|
|
133
133
|
|
|
134
134
|
if (!doNotPushPath) {
|
|
135
|
+
const title = get(
|
|
136
|
+
page,
|
|
137
|
+
["data", "customSeo", "title"],
|
|
138
|
+
get(page, ["data", "story", "seo", "meta-title"], page.title)
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
if (title) {
|
|
142
|
+
global.document.title = title;
|
|
143
|
+
}
|
|
144
|
+
|
|
135
145
|
history.push({
|
|
136
146
|
pathname,
|
|
137
147
|
search: "",
|
|
@@ -165,8 +175,10 @@ export function maybeNavigateTo(path, store) {
|
|
|
165
175
|
*/
|
|
166
176
|
export function maybeSetUrl(path, title) {
|
|
167
177
|
if (global.location.pathname === path) return;
|
|
168
|
-
|
|
169
|
-
|
|
178
|
+
if (global.history.pushState) {
|
|
179
|
+
global.document.title = title;
|
|
180
|
+
global.history.pushState(null, title, path);
|
|
181
|
+
}
|
|
170
182
|
}
|
|
171
183
|
|
|
172
184
|
/**
|
|
@@ -183,7 +195,7 @@ export function renderComponent(clazz, container, store, props = {}, callback) {
|
|
|
183
195
|
|
|
184
196
|
const containerEle = document.getElementById(container);
|
|
185
197
|
|
|
186
|
-
if(!containerEle){
|
|
198
|
+
if (!containerEle) {
|
|
187
199
|
console && console.log(`Rendering component on DOM id ${container} FAILED, node not available`);
|
|
188
200
|
return null;
|
|
189
201
|
}
|
|
@@ -206,16 +218,16 @@ export function renderIsomorphicComponent(container, store, pickComponent, props
|
|
|
206
218
|
if (!store.getState().qt.disableIsomorphicComponent) {
|
|
207
219
|
pickComponentWrapper = makePickComponentSync(pickComponent);
|
|
208
220
|
return pickComponentWrapper
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
.preloadComponent(store.getState().qt.pageType, store.getState().qt.subPageType)
|
|
222
|
+
.then(() =>
|
|
223
|
+
renderComponent(
|
|
224
|
+
IsomorphicComponent,
|
|
225
|
+
container,
|
|
226
|
+
store,
|
|
227
|
+
Object.assign({ pickComponent: pickComponentWrapper }, props),
|
|
228
|
+
() => store.dispatch({ type: CLIENT_SIDE_RENDERED })
|
|
229
|
+
)
|
|
230
|
+
);
|
|
219
231
|
}
|
|
220
232
|
console && console.log("IsomorphicComponent is disabled");
|
|
221
233
|
}
|
|
@@ -264,15 +276,15 @@ export function startApp(renderApplication, reducers, opts) {
|
|
|
264
276
|
const path = `${location.pathname}${location.search || ""}`;
|
|
265
277
|
const staticData = global.staticPageStoreContent || getJsonContent("static-page");
|
|
266
278
|
const dataPromise = staticData
|
|
267
|
-
|
|
268
|
-
|
|
279
|
+
? Promise.resolve(staticData.qt)
|
|
280
|
+
: getRouteData(path, { existingFetch: global.initialFetch });
|
|
269
281
|
|
|
270
282
|
startAnalytics();
|
|
271
283
|
|
|
272
284
|
const store = createQtStore(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
285
|
+
reducers,
|
|
286
|
+
(staticData && staticData.qt) || global.initialPage || getJsonContent("initial-page") || {},
|
|
287
|
+
{}
|
|
276
288
|
);
|
|
277
289
|
|
|
278
290
|
if (opts.preRenderApplication) {
|
|
@@ -314,9 +326,9 @@ export function startApp(renderApplication, reducers, opts) {
|
|
|
314
326
|
|
|
315
327
|
if (page.title) {
|
|
316
328
|
global.document.title = get(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
329
|
+
page,
|
|
330
|
+
["data", "customSeo", "title"],
|
|
331
|
+
get(page, ["data", "story", "seo", "meta-title"], page.title)
|
|
320
332
|
);
|
|
321
333
|
}
|
|
322
334
|
return store;
|