@faststore/core 3.0.10 → 3.0.12
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/498.js +1 -1
- package/.next/server/chunks/640.js +1 -1
- package/.next/server/chunks/646.js +3 -3
- package/.next/server/chunks/997.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.js +1 -1
- package/.next/server/pages/500.js +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/account.html +2 -2
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/login.js +1 -1
- package/.next/server/pages/s.js +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/{_w3buzprZPxAphF4f8eFf → YyyfSkn4MlzCeIY09phdk}/_buildManifest.js +1 -1
- package/.next/static/chunks/pages/{_app-6516d0c2c7e0e686.js → _app-ad8623e78bc5b766.js} +1 -1
- package/.next/trace +91 -91
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +9 -9
- package/cms/faststore/content-types.json +6 -0
- package/cms/faststore/sections.json +18 -0
- package/faststore.config.default.js +4 -0
- package/package.json +2 -2
- package/src/components/cms/GlobalSections.tsx +17 -1
- package/src/components/templates/LandingPage/LandingPage.tsx +19 -2
- package/src/pages/[...slug].tsx +28 -6
- package/src/pages/[slug]/p.tsx +23 -7
- package/src/pages/index.tsx +24 -8
- package/src/pages/s.tsx +25 -9
- package/src/server/cms.ts +26 -0
- /package/.next/static/{_w3buzprZPxAphF4f8eFf → YyyfSkn4MlzCeIY09phdk}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$ yarn partytown & yarn generate && next build
|
|
2
|
-
$ faststore generate-graphql -c
|
|
3
2
|
$ partytown copylib ./public/~partytown
|
|
4
3
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
4
|
+
$ faststore generate-graphql -c
|
|
5
5
|
success - GraphQL schema, types, and optimizations successfully generated 🎉
|
|
6
6
|
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
|
|
7
7
|
Attention: Next.js now collects completely anonymous telemetry regarding usage.
|
|
@@ -53,7 +53,7 @@ Route (pages) Size First Load JS
|
|
|
53
53
|
+ First Load JS shared by all 96.5 kB
|
|
54
54
|
├ chunks/framework-8e279965036b6169.js 45.4 kB
|
|
55
55
|
├ chunks/main-6f63f6746cc029db.js 33.1 kB
|
|
56
|
-
├ chunks/pages/_app-
|
|
56
|
+
├ chunks/pages/_app-ad8623e78bc5b766.js 12.5 kB
|
|
57
57
|
├ chunks/webpack-b4a2fdf4ef127bb7.js 2.45 kB
|
|
58
58
|
└ css/5d1f64b61ea581f4.css 3.05 kB
|
|
59
59
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
$ jest
|
|
2
|
-
PASS test/server/index.test.ts (
|
|
2
|
+
PASS test/server/index.test.ts (21.304 s)
|
|
3
3
|
FastStore GraphQL Layer
|
|
4
4
|
@faststore/api
|
|
5
|
-
✓ should return a valid GraphQL schema (
|
|
6
|
-
✓ should return a valid GraphQL schema contain all expected types (
|
|
5
|
+
✓ should return a valid GraphQL schema (6 ms)
|
|
6
|
+
✓ should return a valid GraphQL schema contain all expected types (5 ms)
|
|
7
7
|
✓ should return a valid GraphQL schema contain all expected queries (1 ms)
|
|
8
8
|
✓ should return a valid GraphQL schema contain all expected mutations (1 ms)
|
|
9
9
|
VTEX API Extension
|
|
10
|
-
✓ getTypeDefsFromFolder function should return an Array (
|
|
10
|
+
✓ getTypeDefsFromFolder function should return an Array (5 ms)
|
|
11
11
|
Third Party API Extension
|
|
12
|
-
✓ getTypeDefsFromFolder function should return an Array (
|
|
12
|
+
✓ getTypeDefsFromFolder function should return an Array (4 ms)
|
|
13
13
|
Final Schema after merging
|
|
14
|
-
✓ should return a valid merged GraphQL schema (
|
|
14
|
+
✓ should return a valid merged GraphQL schema (29 ms)
|
|
15
15
|
Envelop
|
|
16
|
-
✓ should exist with its plugins (
|
|
17
|
-
✓ should handle options and execute (
|
|
16
|
+
✓ should exist with its plugins (32 ms)
|
|
17
|
+
✓ should handle options and execute (125 ms)
|
|
18
18
|
|
|
19
19
|
Test Suites: 1 passed, 1 total
|
|
20
20
|
Tests: 9 passed, 9 total
|
|
21
21
|
Snapshots: 0 total
|
|
22
|
-
Time:
|
|
22
|
+
Time: 21.349 s
|
|
23
23
|
Ran all test suites.
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
{
|
|
3
3
|
"id": "globalSections",
|
|
4
4
|
"name": "Global Sections",
|
|
5
|
+
"scopes": ["global"],
|
|
5
6
|
"configurationSchemaSets": [],
|
|
6
7
|
"isSingleton": true
|
|
7
8
|
},
|
|
8
9
|
{
|
|
9
10
|
"id": "landingPage",
|
|
10
11
|
"name": "Landing Page",
|
|
12
|
+
"scopes": ["landing", "custom"],
|
|
11
13
|
"configurationSchemaSets": [
|
|
12
14
|
{
|
|
13
15
|
"name": "Settings",
|
|
@@ -53,6 +55,7 @@
|
|
|
53
55
|
{
|
|
54
56
|
"id": "home",
|
|
55
57
|
"name": "Home",
|
|
58
|
+
"scopes": ["home"],
|
|
56
59
|
"isSingleton": true,
|
|
57
60
|
"configurationSchemaSets": [
|
|
58
61
|
{
|
|
@@ -99,12 +102,14 @@
|
|
|
99
102
|
{
|
|
100
103
|
"id": "pdp",
|
|
101
104
|
"name": "Product Page",
|
|
105
|
+
"scopes": ["pdp"],
|
|
102
106
|
"isSingleton": true,
|
|
103
107
|
"configurationSchemaSets": []
|
|
104
108
|
},
|
|
105
109
|
{
|
|
106
110
|
"id": "plp",
|
|
107
111
|
"name": "Product List Page",
|
|
112
|
+
"scopes": ["plp"],
|
|
108
113
|
"isSingleton": true,
|
|
109
114
|
"configurationSchemaSets": [
|
|
110
115
|
{
|
|
@@ -158,6 +163,7 @@
|
|
|
158
163
|
{
|
|
159
164
|
"id": "search",
|
|
160
165
|
"name": "Search Page",
|
|
166
|
+
"scopes": ["plp", "search"],
|
|
161
167
|
"isSingleton": true,
|
|
162
168
|
"configurationSchemaSets": [
|
|
163
169
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "Search",
|
|
4
|
+
"requiredScopes": [],
|
|
4
5
|
"schema": {
|
|
5
6
|
"title": "Search Bar",
|
|
6
7
|
"type": "object",
|
|
@@ -145,6 +146,7 @@
|
|
|
145
146
|
},
|
|
146
147
|
{
|
|
147
148
|
"name": "Navbar",
|
|
149
|
+
"requiredScopes": [],
|
|
148
150
|
"schema": {
|
|
149
151
|
"title": "Navbar",
|
|
150
152
|
"type": "object",
|
|
@@ -369,6 +371,7 @@
|
|
|
369
371
|
},
|
|
370
372
|
{
|
|
371
373
|
"name": "Alert",
|
|
374
|
+
"requiredScopes": [],
|
|
372
375
|
"schema": {
|
|
373
376
|
"title": "Alert",
|
|
374
377
|
"description": "Add an alert",
|
|
@@ -416,6 +419,7 @@
|
|
|
416
419
|
},
|
|
417
420
|
{
|
|
418
421
|
"name": "Footer",
|
|
422
|
+
"requiredScopes": [],
|
|
419
423
|
"schema": {
|
|
420
424
|
"title": "Footer",
|
|
421
425
|
"description": "Footer displayed on all pages",
|
|
@@ -661,6 +665,7 @@
|
|
|
661
665
|
},
|
|
662
666
|
{
|
|
663
667
|
"name": "BannerText",
|
|
668
|
+
"requiredScopes": [],
|
|
664
669
|
"schema": {
|
|
665
670
|
"title": "Banner Text",
|
|
666
671
|
"description": "Add a quick promotion with a text/action pair",
|
|
@@ -712,6 +717,7 @@
|
|
|
712
717
|
},
|
|
713
718
|
{
|
|
714
719
|
"name": "Hero",
|
|
720
|
+
"requiredScopes": [],
|
|
715
721
|
"schema": {
|
|
716
722
|
"title": "Hero",
|
|
717
723
|
"description": "Add a quick promotion with an image/action pair",
|
|
@@ -779,6 +785,7 @@
|
|
|
779
785
|
},
|
|
780
786
|
{
|
|
781
787
|
"name": "Incentives",
|
|
788
|
+
"requiredScopes": [],
|
|
782
789
|
"schema": {
|
|
783
790
|
"title": "Incentives",
|
|
784
791
|
"description": "Add Incentives to your shopper",
|
|
@@ -836,6 +843,7 @@
|
|
|
836
843
|
},
|
|
837
844
|
{
|
|
838
845
|
"name": "ProductShelf",
|
|
846
|
+
"requiredScopes": [],
|
|
839
847
|
"schema": {
|
|
840
848
|
"title": "Product Shelf",
|
|
841
849
|
"description": "Add custom shelves to your store",
|
|
@@ -937,6 +945,7 @@
|
|
|
937
945
|
},
|
|
938
946
|
{
|
|
939
947
|
"name": "CrossSellingShelf",
|
|
948
|
+
"requiredScopes": ["pdp", "custom"],
|
|
940
949
|
"schema": {
|
|
941
950
|
"title": "Cross Selling Shelf",
|
|
942
951
|
"description": "Add cross selling product data to your users",
|
|
@@ -971,6 +980,7 @@
|
|
|
971
980
|
},
|
|
972
981
|
{
|
|
973
982
|
"name": "ProductTiles",
|
|
983
|
+
"requiredScopes": [],
|
|
974
984
|
"schema": {
|
|
975
985
|
"title": "Product Tiles",
|
|
976
986
|
"description": "Add custom highlights to your store",
|
|
@@ -1050,6 +1060,7 @@
|
|
|
1050
1060
|
},
|
|
1051
1061
|
{
|
|
1052
1062
|
"name": "Newsletter",
|
|
1063
|
+
"requiredScopes": [],
|
|
1053
1064
|
"schema": {
|
|
1054
1065
|
"title": "Newsletter",
|
|
1055
1066
|
"description": "Allow users to subscribe to your updates",
|
|
@@ -1191,6 +1202,7 @@
|
|
|
1191
1202
|
},
|
|
1192
1203
|
{
|
|
1193
1204
|
"name": "BannerNewsletter",
|
|
1205
|
+
"requiredScopes": [],
|
|
1194
1206
|
"schema": {
|
|
1195
1207
|
"title": "Banner Newsletter",
|
|
1196
1208
|
"description": "Add newsletter with a banner",
|
|
@@ -1374,6 +1386,7 @@
|
|
|
1374
1386
|
},
|
|
1375
1387
|
{
|
|
1376
1388
|
"name": "Breadcrumb",
|
|
1389
|
+
"requiredScopes": ["pdp", "plp"],
|
|
1377
1390
|
"schema": {
|
|
1378
1391
|
"title": "Breadcrumb",
|
|
1379
1392
|
"description": "Configure the breadcrumb icon and depth",
|
|
@@ -1395,6 +1408,7 @@
|
|
|
1395
1408
|
},
|
|
1396
1409
|
{
|
|
1397
1410
|
"name": "ProductDetails",
|
|
1411
|
+
"requiredScopes": ["pdp"],
|
|
1398
1412
|
"schema": {
|
|
1399
1413
|
"title": "Product Details",
|
|
1400
1414
|
"type": "object",
|
|
@@ -1530,6 +1544,7 @@
|
|
|
1530
1544
|
},
|
|
1531
1545
|
{
|
|
1532
1546
|
"name": "ProductGallery",
|
|
1547
|
+
"requiredScopes": ["plp", "search"],
|
|
1533
1548
|
"schema": {
|
|
1534
1549
|
"title": "Product Gallery",
|
|
1535
1550
|
"type": "object",
|
|
@@ -1726,6 +1741,7 @@
|
|
|
1726
1741
|
},
|
|
1727
1742
|
{
|
|
1728
1743
|
"name": "CartSidebar",
|
|
1744
|
+
"requiredScopes": [],
|
|
1729
1745
|
"schema": {
|
|
1730
1746
|
"title": "Cart Sidebar",
|
|
1731
1747
|
"type": "object",
|
|
@@ -1821,6 +1837,7 @@
|
|
|
1821
1837
|
},
|
|
1822
1838
|
{
|
|
1823
1839
|
"name": "RegionBar",
|
|
1840
|
+
"requiredScopes": [],
|
|
1824
1841
|
"schema": {
|
|
1825
1842
|
"title": "Region Bar",
|
|
1826
1843
|
"type": "object",
|
|
@@ -1878,6 +1895,7 @@
|
|
|
1878
1895
|
},
|
|
1879
1896
|
{
|
|
1880
1897
|
"name": "RegionModal",
|
|
1898
|
+
"requiredScopes": [],
|
|
1881
1899
|
"schema": {
|
|
1882
1900
|
"title": "Region Modal",
|
|
1883
1901
|
"type": "object",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"node": "18.19.0",
|
|
129
129
|
"yarn": "1.19.1"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "110cdfee8c6b8149f44606b7de82d5488ce90420"
|
|
132
132
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Locator, Section } from '@vtex/client-cms'
|
|
2
2
|
import type { ComponentType } from 'react'
|
|
3
3
|
import { PropsWithChildren, lazy } from 'react'
|
|
4
|
+
import storeConfig from 'faststore.config'
|
|
4
5
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
5
|
-
import { PageContentType, getPage } from 'src/server/cms'
|
|
6
|
+
import { PageContentType, getPage, getPageByVersionId } from 'src/server/cms'
|
|
6
7
|
|
|
7
8
|
import Toast from 'src/components/common/Toast'
|
|
8
9
|
import RenderSections from './RenderSections'
|
|
@@ -50,6 +51,21 @@ export default GlobalSections
|
|
|
50
51
|
export const getGlobalSectionsData = async (
|
|
51
52
|
previewData: Locator
|
|
52
53
|
): Promise<GlobalSectionsData> => {
|
|
54
|
+
if (storeConfig.cms.data) {
|
|
55
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
56
|
+
const page = cmsData[GLOBAL_SECTIONS_CONTENT_TYPE][0]
|
|
57
|
+
|
|
58
|
+
if (page) {
|
|
59
|
+
const pageData = await getPageByVersionId<PageContentType>({
|
|
60
|
+
contentType: GLOBAL_SECTIONS_CONTENT_TYPE,
|
|
61
|
+
documentId: page.documentId,
|
|
62
|
+
versionId: page.versionId,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return pageData
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
const { sections } = await getPage<PageContentType>({
|
|
54
70
|
...(previewData?.contentType === GLOBAL_SECTIONS_CONTENT_TYPE &&
|
|
55
71
|
previewData),
|
|
@@ -10,11 +10,11 @@ import { OverriddenDefaultNewsletter as Newsletter } from 'src/components/sectio
|
|
|
10
10
|
import { OverriddenDefaultProductShelf as ProductShelf } from 'src/components/sections/ProductShelf/OverriddenDefaultProductShelf'
|
|
11
11
|
import Incentives from 'src/components/sections/Incentives'
|
|
12
12
|
import ProductTiles from 'src/components/sections/ProductTiles'
|
|
13
|
-
import { getPage } from 'src/server/cms'
|
|
13
|
+
import { getPage, getPageByVersionId } from 'src/server/cms'
|
|
14
14
|
import type { PageContentType } from 'src/server/cms'
|
|
15
15
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
16
16
|
|
|
17
|
-
import storeConfig from '
|
|
17
|
+
import storeConfig from 'faststore.config'
|
|
18
18
|
|
|
19
19
|
/* A list of components that can be used in the CMS. */
|
|
20
20
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -85,6 +85,23 @@ export const getLandingPageBySlug = async (
|
|
|
85
85
|
previewData: Locator
|
|
86
86
|
) => {
|
|
87
87
|
try {
|
|
88
|
+
if (storeConfig.cms.data) {
|
|
89
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
90
|
+
const pageBySlug = cmsData['landingPage'].find((page) => {
|
|
91
|
+
slug === page.settings?.seo?.slug
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
if (pageBySlug) {
|
|
95
|
+
const landingPageData = await getPageByVersionId<PageContentType>({
|
|
96
|
+
contentType: 'landingPage',
|
|
97
|
+
documentId: pageBySlug.documentId,
|
|
98
|
+
versionId: pageBySlug.versionId,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
return landingPageData
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
const landingPageData = await getPage<PageContentType>({
|
|
89
106
|
...(previewData?.contentType === 'landingPage'
|
|
90
107
|
? previewData
|
package/src/pages/[...slug].tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNotFoundError } from '@faststore/api'
|
|
2
2
|
import type { GetStaticPaths, GetStaticProps } from 'next'
|
|
3
|
+
import storeConfig from 'faststore.config'
|
|
3
4
|
|
|
4
5
|
import { gql } from '@generated'
|
|
5
6
|
import type {
|
|
@@ -14,7 +15,12 @@ import GlobalSections, {
|
|
|
14
15
|
getGlobalSectionsData,
|
|
15
16
|
GlobalSectionsData,
|
|
16
17
|
} from 'src/components/cms/GlobalSections'
|
|
17
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
getPage,
|
|
20
|
+
getPageByVersionId,
|
|
21
|
+
PageContentType,
|
|
22
|
+
PLPContentType,
|
|
23
|
+
} from 'src/server/cms'
|
|
18
24
|
import ProductListingPage, {
|
|
19
25
|
ProductListingPageProps,
|
|
20
26
|
} from 'src/components/templates/ProductListingPage'
|
|
@@ -100,7 +106,7 @@ export const getStaticProps: GetStaticProps<
|
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
|
|
103
|
-
const [{ data, errors = [] }
|
|
109
|
+
const [{ data, errors = [] }] = await Promise.all([
|
|
104
110
|
execute<
|
|
105
111
|
ServerCollectionPageQueryQueryVariables,
|
|
106
112
|
ServerCollectionPageQueryQuery
|
|
@@ -108,11 +114,27 @@ export const getStaticProps: GetStaticProps<
|
|
|
108
114
|
variables: { slug },
|
|
109
115
|
operation: query,
|
|
110
116
|
}),
|
|
111
|
-
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
let pageData
|
|
120
|
+
|
|
121
|
+
if (storeConfig.cms.data) {
|
|
122
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
123
|
+
const page = cmsData['plp'][0]
|
|
124
|
+
|
|
125
|
+
if (page) {
|
|
126
|
+
pageData = await getPageByVersionId<PLPContentType>({
|
|
127
|
+
contentType: 'plp',
|
|
128
|
+
documentId: page.documentId,
|
|
129
|
+
versionId: page.versionId,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
pageData = await getPage<PLPContentType>({
|
|
112
134
|
...(previewData?.contentType === 'plp' ? previewData : null),
|
|
113
135
|
contentType: 'plp',
|
|
114
|
-
})
|
|
115
|
-
|
|
136
|
+
})
|
|
137
|
+
}
|
|
116
138
|
|
|
117
139
|
const notFound = errors.find(isNotFoundError)
|
|
118
140
|
|
|
@@ -130,7 +152,7 @@ export const getStaticProps: GetStaticProps<
|
|
|
130
152
|
return {
|
|
131
153
|
props: {
|
|
132
154
|
data,
|
|
133
|
-
page,
|
|
155
|
+
page: pageData,
|
|
134
156
|
globalSections: await globalSectionsPromise,
|
|
135
157
|
type: 'plp',
|
|
136
158
|
key: slug,
|
package/src/pages/[slug]/p.tsx
CHANGED
|
@@ -21,13 +21,13 @@ import { useSession } from 'src/sdk/session'
|
|
|
21
21
|
import { mark } from 'src/sdk/tests/mark'
|
|
22
22
|
import { execute } from 'src/server'
|
|
23
23
|
import type { PDPContentType } from 'src/server/cms'
|
|
24
|
-
import { getPage } from 'src/server/cms'
|
|
24
|
+
import { getPage, getPageByVersionId } from 'src/server/cms'
|
|
25
25
|
|
|
26
26
|
import GlobalSections, {
|
|
27
27
|
GlobalSectionsData,
|
|
28
28
|
getGlobalSectionsData,
|
|
29
29
|
} from 'src/components/cms/GlobalSections'
|
|
30
|
-
import storeConfig from '
|
|
30
|
+
import storeConfig from 'faststore.config'
|
|
31
31
|
import { useProductQuery } from 'src/sdk/product/useProductQuery'
|
|
32
32
|
import PageProvider, { PDPContext } from 'src/sdk/overrides/PageProvider'
|
|
33
33
|
|
|
@@ -200,18 +200,34 @@ export const getStaticProps: GetStaticProps<
|
|
|
200
200
|
Locator
|
|
201
201
|
> = async ({ params, previewData }) => {
|
|
202
202
|
const slug = params?.slug ?? ''
|
|
203
|
-
const [searchResult,
|
|
203
|
+
const [searchResult, globalSections] = await Promise.all([
|
|
204
204
|
execute<ServerProductQueryQueryVariables, ServerProductQueryQuery>({
|
|
205
205
|
variables: { locator: [{ key: 'slug', value: slug }] },
|
|
206
206
|
operation: query,
|
|
207
207
|
}),
|
|
208
|
-
getPage<PDPContentType>({
|
|
209
|
-
...(previewData?.contentType === 'pdp' ? previewData : null),
|
|
210
|
-
contentType: 'pdp',
|
|
211
|
-
}),
|
|
212
208
|
getGlobalSectionsData(previewData),
|
|
213
209
|
])
|
|
214
210
|
|
|
211
|
+
let cmsPage
|
|
212
|
+
|
|
213
|
+
if (storeConfig.cms.data) {
|
|
214
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
215
|
+
const page = cmsData['pdp'][0]
|
|
216
|
+
|
|
217
|
+
if (page) {
|
|
218
|
+
cmsPage = getPageByVersionId<PDPContentType>({
|
|
219
|
+
contentType: 'pdp',
|
|
220
|
+
documentId: page.documentId,
|
|
221
|
+
versionId: page.versionId,
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
cmsPage = getPage<PDPContentType>({
|
|
226
|
+
...(previewData?.contentType === 'pdp' ? previewData : null),
|
|
227
|
+
contentType: 'pdp',
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
215
231
|
const { data, errors = [] } = searchResult
|
|
216
232
|
|
|
217
233
|
const notFound = errors.find(isNotFoundError)
|
package/src/pages/index.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import ProductTiles from 'src/components/sections/ProductTiles'
|
|
|
13
13
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
14
14
|
import { mark } from 'src/sdk/tests/mark'
|
|
15
15
|
import type { PageContentType } from 'src/server/cms'
|
|
16
|
-
import { getPage } from 'src/server/cms'
|
|
16
|
+
import { getPage, getPageByVersionId } from 'src/server/cms'
|
|
17
17
|
|
|
18
18
|
import GlobalSections, {
|
|
19
19
|
GlobalSectionsData,
|
|
@@ -85,13 +85,29 @@ export const getStaticProps: GetStaticProps<
|
|
|
85
85
|
Record<string, string>,
|
|
86
86
|
Locator
|
|
87
87
|
> = async ({ previewData }) => {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const globalSections = await getGlobalSectionsData(previewData)
|
|
89
|
+
|
|
90
|
+
if (storeConfig.cms.data) {
|
|
91
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
92
|
+
const page = cmsData['home'][0]
|
|
93
|
+
|
|
94
|
+
if (page) {
|
|
95
|
+
const pageData = await getPageByVersionId<PageContentType>({
|
|
96
|
+
contentType: 'home',
|
|
97
|
+
documentId: page.documentId,
|
|
98
|
+
versionId: page.versionId,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
props: { page: pageData, globalSections },
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const page = await getPage<PageContentType>({
|
|
108
|
+
...(previewData?.contentType === 'home' && previewData),
|
|
109
|
+
contentType: 'home',
|
|
110
|
+
})
|
|
95
111
|
|
|
96
112
|
return {
|
|
97
113
|
props: { page, globalSections },
|
package/src/pages/s.tsx
CHANGED
|
@@ -19,8 +19,8 @@ import GlobalSections, {
|
|
|
19
19
|
getGlobalSectionsData,
|
|
20
20
|
GlobalSectionsData,
|
|
21
21
|
} from 'src/components/cms/GlobalSections'
|
|
22
|
-
import { getPage, SearchContentType } from 'src/server/cms'
|
|
23
|
-
import storeConfig from '
|
|
22
|
+
import { getPage, getPageByVersionId, SearchContentType } from 'src/server/cms'
|
|
23
|
+
import storeConfig from 'faststore.config'
|
|
24
24
|
import SearchPage from 'src/components/templates/SearchPage/SearchPage'
|
|
25
25
|
|
|
26
26
|
type Props = {
|
|
@@ -118,13 +118,29 @@ export const getStaticProps: GetStaticProps<
|
|
|
118
118
|
Record<string, string>,
|
|
119
119
|
Locator
|
|
120
120
|
> = async ({ previewData }) => {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
const globalSections = await getGlobalSectionsData(previewData)
|
|
122
|
+
|
|
123
|
+
if (storeConfig.cms.data) {
|
|
124
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
125
|
+
const page = cmsData['search'][0]
|
|
126
|
+
|
|
127
|
+
if (page) {
|
|
128
|
+
const pageData = await getPageByVersionId<SearchContentType>({
|
|
129
|
+
contentType: 'search',
|
|
130
|
+
documentId: page.documentId,
|
|
131
|
+
versionId: page.versionId,
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
props: { page: pageData, globalSections },
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const page = await getPage<SearchContentType>({
|
|
141
|
+
...(previewData?.contentType === 'search' ? previewData : null),
|
|
142
|
+
contentType: 'search',
|
|
143
|
+
})
|
|
128
144
|
|
|
129
145
|
return {
|
|
130
146
|
props: {
|
package/src/server/cms.ts
CHANGED
|
@@ -39,6 +39,32 @@ export const getPage = async <T extends ContentData>(options: Options) => {
|
|
|
39
39
|
return pages[0] as T
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export type VersionOptions = {
|
|
43
|
+
contentType: string
|
|
44
|
+
documentId: string
|
|
45
|
+
versionId: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const getPageByVersionId = async <T extends ContentData>(
|
|
49
|
+
options: VersionOptions
|
|
50
|
+
) => {
|
|
51
|
+
const result = await clientCMS
|
|
52
|
+
.getCMSPage(options)
|
|
53
|
+
.then((page) => ({ data: [page] }))
|
|
54
|
+
|
|
55
|
+
const pages = result.data
|
|
56
|
+
|
|
57
|
+
if (!pages[0]) {
|
|
58
|
+
throw new MissingContentError(options)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (pages.length !== 1) {
|
|
62
|
+
throw new MultipleContentError(options)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return pages[0] as T
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
type ProductGallerySettings = {
|
|
43
69
|
settings: {
|
|
44
70
|
productGallery: {
|
|
File without changes
|