@faststore/core 3.22.3 → 3.24.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.
Files changed (87) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +16 -16
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/webpack/client-production/0.pack +0 -0
  6. package/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/.next/cache/webpack/server-production/0.pack +0 -0
  8. package/.next/cache/webpack/server-production/index.pack +0 -0
  9. package/.next/prerender-manifest.js +1 -1
  10. package/.next/prerender-manifest.json +1 -1
  11. package/.next/react-loadable-manifest.json +1 -1
  12. package/.next/routes-manifest.json +1 -1
  13. package/.next/server/chunks/{9622.js → 7355.js} +3 -3
  14. package/.next/server/chunks/7816.js +1 -1
  15. package/.next/server/functions-config-manifest.json +1 -1
  16. package/.next/server/middleware-build-manifest.js +1 -1
  17. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  18. package/.next/server/pages/404.js +1 -1
  19. package/.next/server/pages/404.js.nft.json +1 -1
  20. package/.next/server/pages/500.js +1 -1
  21. package/.next/server/pages/500.js.nft.json +1 -1
  22. package/.next/server/pages/[...slug].js +1 -1
  23. package/.next/server/pages/[...slug].js.nft.json +1 -1
  24. package/.next/server/pages/[slug]/p.js +1 -1
  25. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  26. package/.next/server/pages/_app.js.nft.json +1 -1
  27. package/.next/server/pages/_document.js.nft.json +1 -1
  28. package/.next/server/pages/_error.js.nft.json +1 -1
  29. package/.next/server/pages/account.js +1 -1
  30. package/.next/server/pages/account.js.nft.json +1 -1
  31. package/.next/server/pages/api/graphql.js +1 -1
  32. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  33. package/.next/server/pages/api/health/live.js.nft.json +1 -1
  34. package/.next/server/pages/api/health/ready.js.nft.json +1 -1
  35. package/.next/server/pages/api/preview.js.nft.json +1 -1
  36. package/.next/server/pages/checkout.js +1 -1
  37. package/.next/server/pages/checkout.js.nft.json +1 -1
  38. package/.next/server/pages/en-US/404.html +2 -2
  39. package/.next/server/pages/en-US/404.json +1 -1
  40. package/.next/server/pages/en-US/500.html +2 -2
  41. package/.next/server/pages/en-US/500.json +1 -1
  42. package/.next/server/pages/en-US/account.html +2 -2
  43. package/.next/server/pages/en-US/account.json +1 -1
  44. package/.next/server/pages/en-US/checkout.html +2 -2
  45. package/.next/server/pages/en-US/checkout.json +1 -1
  46. package/.next/server/pages/en-US/login.html +2 -2
  47. package/.next/server/pages/en-US/login.json +1 -1
  48. package/.next/server/pages/en-US/s.html +2 -2
  49. package/.next/server/pages/en-US/s.json +1 -1
  50. package/.next/server/pages/en-US.html +2 -2
  51. package/.next/server/pages/en-US.json +1 -1
  52. package/.next/server/pages/index.js +1 -1
  53. package/.next/server/pages/index.js.nft.json +1 -1
  54. package/.next/server/pages/login.js +1 -1
  55. package/.next/server/pages/login.js.nft.json +1 -1
  56. package/.next/server/pages/s.js +1 -1
  57. package/.next/server/pages/s.js.nft.json +1 -1
  58. package/.next/static/{D3QeBDlqm3kdTCp_EvAVS → cCDxvGnNemGOAZByQDbQR}/_buildManifest.js +1 -1
  59. package/.next/static/chunks/9180.a9391411a02a643d.js +1 -0
  60. package/.next/static/chunks/pages/{404-3d151353c4e53a04.js → 404-32bb6fa89ab66aca.js} +1 -1
  61. package/.next/static/chunks/pages/{500-b7900a231cd5a12d.js → 500-eb359aa3bffe64a6.js} +1 -1
  62. package/.next/static/chunks/pages/{login-03e155dd4f803d5d.js → login-6678b657c8c13867.js} +1 -1
  63. package/.next/static/chunks/{webpack-73f875a3fea96a4a.js → webpack-0d600424e508dae8.js} +1 -1
  64. package/.next/trace +121 -121
  65. package/.turbo/turbo-build.log +16 -10
  66. package/.turbo/turbo-test.log +8 -7
  67. package/CHANGELOG.md +10 -0
  68. package/cms/faststore/content-types.json +14 -0
  69. package/package.json +3 -3
  70. package/src/components/cms/GlobalSections.tsx +28 -7
  71. package/src/experimental/searchServerSideFunctions/getServerSideProps.ts +49 -12
  72. package/src/experimental/searchServerSideFunctions/getStaticProps.ts +48 -15
  73. package/src/pages/404.tsx +25 -9
  74. package/src/pages/500.tsx +25 -9
  75. package/src/pages/[...slug].tsx +39 -8
  76. package/src/pages/[slug]/p.tsx +24 -3
  77. package/src/pages/account.tsx +20 -2
  78. package/src/pages/checkout.tsx +20 -2
  79. package/src/pages/index.tsx +24 -3
  80. package/src/pages/login.tsx +25 -9
  81. package/src/sdk/error/ChildrenSectionNotFoundError/ChildrenSectionNotFoundError.ts +6 -0
  82. package/src/sdk/error/ChildrenSectionNotFoundError/index.ts +1 -0
  83. package/src/server/cms/global.ts +38 -0
  84. package/src/server/cms/index.ts +1 -1
  85. package/test/server/cms/global.test.ts +86 -0
  86. package/.next/static/chunks/9180.ca246b121565be34.js +0 -1
  87. /package/.next/static/{D3QeBDlqm3kdTCp_EvAVS → cCDxvGnNemGOAZByQDbQR}/_ssgManifest.js +0 -0
@@ -1,23 +1,23 @@
1
1
 
2
- > @faststore/core@3.22.2 prebuild /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.23.0 prebuild /home/runner/work/faststore/faststore/packages/core
3
3
  > na run partytown && na run generate
4
4
 
5
5
 
6
- > @faststore/core@3.22.2 partytown /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@3.23.0 partytown /home/runner/work/faststore/faststore/packages/core
7
7
  > partytown copylib ./public/~partytown
8
8
 
9
9
  Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
10
10
 
11
- > @faststore/core@3.22.2 generate /home/runner/work/faststore/faststore/packages/core
11
+ > @faststore/core@3.23.0 generate /home/runner/work/faststore/faststore/packages/core
12
12
  > na run generate:schema && na run generate:codegen && na run format:generated
13
13
 
14
14
 
15
- > @faststore/core@3.22.2 generate:schema /home/runner/work/faststore/faststore/packages/core
15
+ > @faststore/core@3.23.0 generate:schema /home/runner/work/faststore/faststore/packages/core
16
16
  > tsx src/server/generator/generateGraphQLSchemaFile.ts
17
17
 
18
18
  Schema GraphQL file generated successfully
19
19
 
20
- > @faststore/core@3.22.2 generate:codegen /home/runner/work/faststore/faststore/packages/core
20
+ > @faststore/core@3.23.0 generate:codegen /home/runner/work/faststore/faststore/packages/core
21
21
  > graphql-codegen
22
22
 
23
23
  [STARTED] Parse Configuration
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
37
37
  [CLI] Loading Documents
38
38
  [CLI] Generating output
39
39
 
40
- > @faststore/core@3.22.2 format:generated /home/runner/work/faststore/faststore/packages/core
40
+ > @faststore/core@3.23.0 format:generated /home/runner/work/faststore/faststore/packages/core
41
41
  > prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
42
42
 
43
43
 
44
- > @faststore/core@3.22.2 build /home/runner/work/faststore/faststore/packages/core
44
+ > @faststore/core@3.23.0 build /home/runner/work/faststore/faststore/packages/core
45
45
  > next build
46
46
 
47
47
  ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
@@ -58,11 +58,17 @@ https://nextjs.org/telemetry
58
58
  ✓ Compiled successfully
59
59
  Collecting page data ...
60
60
  Generating static pages (0/7) ...
61
+ BannerText not found. Add a new component for this section or remove it from the CMS
62
+ BannerText not found. Add a new component for this section or remove it from the CMS
61
63
 
62
64
  Generating static pages (1/7)
63
-
64
65
  Generating static pages (3/7)
65
66
  Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
66
- CustomModalFooterSection not found. Add a new component for this section or remove it from the CMS
67
+ BannerText not found. Add a new component for this section or remove it from the CMS
68
+
67
69
  Generating static pages (3/7)
70
+ BannerText not found. Add a new component for this section or remove it from the CMS
71
+ BannerText not found. Add a new component for this section or remove it from the CMS
68
72
 
69
73
  Generating static pages (5/7)
74
+ CustomModalFooterSection not found. Add a new component for this section or remove it from the CMS
75
+ BannerText not found. Add a new component for this section or remove it from the CMS
70
76
 
71
77
  ✓ Generating static pages (7/7)
72
78
  Finalizing page optimization ...
73
79
  Collecting build traces ...
@@ -90,7 +96,7 @@ Route (pages) Size First Load JS
90
96
  ├ chunks/framework-807b0f81cbc129f0.js 45.4 kB
91
97
  ├ chunks/main-1617ca75abfe1b79.js 33.1 kB
92
98
  ├ chunks/pages/_app-859f97f9c8a57799.js 10.2 kB
93
- ├ chunks/webpack-73f875a3fea96a4a.js 3.58 kB
99
+ ├ chunks/webpack-0d600424e508dae8.js 3.58 kB
94
100
  └ css/2eafb8997a3946dc.css 3.07 kB
95
101
 
96
102
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1,13 +1,14 @@
1
1
 
2
- > @faststore/core@3.22.2 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.23.0 test /home/runner/work/faststore/faststore/packages/core
3
3
  > jest
4
4
 
5
- PASS test/utils/multipleTemplates.test.ts (28.841 s)
6
- PASS test/server/cms/index.test.ts (29.666 s)
7
- PASS test/server/index.test.ts (33.771 s)
5
+ PASS test/server/cms/global.test.ts (29.677 s)
6
+ PASS test/utils/multipleTemplates.test.ts (29.737 s)
7
+ PASS test/server/cms/index.test.ts
8
+ PASS test/server/index.test.ts (34.962 s)
8
9
 
9
- Test Suites: 3 passed, 3 total
10
- Tests: 19 passed, 19 total
10
+ Test Suites: 4 passed, 4 total
11
+ Tests: 22 passed, 22 total
11
12
  Snapshots: 0 total
12
- Time: 34.961 s
13
+ Time: 36.265 s
13
14
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.24.0](https://github.com/vtex/faststore/compare/v3.23.0...v3.24.0) (2025-02-26)
7
+
8
+ ### Features
9
+
10
+ - Multiple global content types ([#2668](https://github.com/vtex/faststore/issues/2668)) ([8555310](https://github.com/vtex/faststore/commit/85553101b1d8f3ec510259007ff1d594ec33c338))
11
+
12
+ # [3.23.0](https://github.com/vtex/faststore/compare/v3.22.3...v3.23.0) (2025-02-26)
13
+
14
+ **Note:** Version bump only for package @faststore/core
15
+
6
16
  ## [3.22.3](https://github.com/vtex/faststore/compare/v3.22.2...v3.22.3) (2025-02-24)
7
17
 
8
18
  ### Bug Fixes
@@ -6,6 +6,20 @@
6
6
  "configurationSchemaSets": [],
7
7
  "isSingleton": true
8
8
  },
9
+ {
10
+ "id": "globalHeaderSections",
11
+ "name": "Global Header Sections",
12
+ "scopes": ["global"],
13
+ "configurationSchemaSets": [],
14
+ "isSingleton": true
15
+ },
16
+ {
17
+ "id": "globalFooterSections",
18
+ "name": "Global Footer Sections",
19
+ "scopes": ["global"],
20
+ "configurationSchemaSets": [],
21
+ "isSingleton": true
22
+ },
9
23
  {
10
24
  "id": "landingPage",
11
25
  "name": "Landing Page",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.22.3",
3
+ "version": "3.24.0",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -44,7 +44,7 @@
44
44
  "@envelop/graphql-jit": "^8.0.3",
45
45
  "@envelop/parser-cache": "^6.0.2",
46
46
  "@envelop/validation-cache": "^6.0.2",
47
- "@faststore/api": "^3.22.2",
47
+ "@faststore/api": "^3.23.0",
48
48
  "@faststore/components": "^3.22.2",
49
49
  "@faststore/graphql-utils": "^3.22.2",
50
50
  "@faststore/lighthouse": "^3.22.2",
@@ -104,5 +104,5 @@
104
104
  "ts-jest": "29.1.1",
105
105
  "typescript": "5.3.2"
106
106
  },
107
- "gitHead": "b218413fdfbcc051aacab14d6f95d1fe82fc8bd1"
107
+ "gitHead": "02a79fb627a9ca1edf65b576102322fd5968e271"
108
108
  }
@@ -3,21 +3,24 @@ import storeConfig from 'discovery.config'
3
3
  import { type PageContentType, getPage } from 'src/server/cms'
4
4
 
5
5
  export const GLOBAL_SECTIONS_CONTENT_TYPE = 'globalSections'
6
+ export const GLOBAL_SECTIONS_HEADER_CONTENT_TYPE = 'globalHeaderSections'
7
+ export const GLOBAL_SECTIONS_FOOTER_CONTENT_TYPE = 'globalFooterSections'
6
8
 
7
9
  export type GlobalSectionsData = {
8
10
  sections: Section[]
9
11
  }
10
12
 
11
- export const getGlobalSectionsData = async (
12
- previewData: Locator
13
+ export const getGlobalSectionsByType = async (
14
+ previewData: Locator,
15
+ contentType: string
13
16
  ): Promise<GlobalSectionsData> => {
14
17
  if (storeConfig.cms.data) {
15
18
  const cmsData = JSON.parse(storeConfig.cms.data)
16
- const page = cmsData[GLOBAL_SECTIONS_CONTENT_TYPE][0]
19
+ const page = cmsData[contentType][0]
17
20
 
18
21
  if (page) {
19
22
  const pageData = getPage<PageContentType>({
20
- contentType: GLOBAL_SECTIONS_CONTENT_TYPE,
23
+ contentType: contentType,
21
24
  documentId: page.documentId,
22
25
  versionId: page.versionId,
23
26
  })
@@ -27,10 +30,28 @@ export const getGlobalSectionsData = async (
27
30
  }
28
31
 
29
32
  const pageData = getPage<PageContentType>({
30
- ...(previewData?.contentType === GLOBAL_SECTIONS_CONTENT_TYPE &&
31
- previewData),
32
- contentType: GLOBAL_SECTIONS_CONTENT_TYPE,
33
+ ...(previewData?.contentType === contentType && previewData),
34
+ contentType: contentType,
33
35
  })
34
36
 
35
37
  return pageData
36
38
  }
39
+
40
+ export const getGlobalSectionsData = (
41
+ previewData: Locator
42
+ ): Promise<GlobalSectionsData>[] => {
43
+ const globalSections = getGlobalSectionsByType(
44
+ previewData,
45
+ GLOBAL_SECTIONS_CONTENT_TYPE
46
+ )
47
+ const globalHeaderSections = getGlobalSectionsByType(
48
+ previewData,
49
+ GLOBAL_SECTIONS_HEADER_CONTENT_TYPE
50
+ )
51
+ const globalFooterSections = getGlobalSectionsByType(
52
+ previewData,
53
+ GLOBAL_SECTIONS_FOOTER_CONTENT_TYPE
54
+ )
55
+
56
+ return [globalSections, globalHeaderSections, globalFooterSections]
57
+ }
@@ -1,10 +1,11 @@
1
1
  import type { GetServerSideProps } from 'next'
2
2
  import type { SearchPageProps } from './getStaticProps'
3
3
 
4
- import { getGlobalSectionsData } from 'src/components/cms/GlobalSections'
5
- import { type SearchContentType, getPage } from 'src/server/cms'
6
4
  import type { Locator } from '@vtex/client-cms'
7
5
  import storeConfig from 'discovery.config'
6
+ import { getGlobalSectionsData } from 'src/components/cms/GlobalSections'
7
+ import { type SearchContentType, getPage } from 'src/server/cms'
8
+ import { injectGlobalSections } from 'src/server/cms/global'
8
9
 
9
10
  export const getServerSideProps: GetServerSideProps<
10
11
  SearchPageProps,
@@ -14,26 +15,62 @@ export const getServerSideProps: GetServerSideProps<
14
15
  const { previewData, query, res } = context
15
16
  const searchTerm = (query.q as string)?.split('+').join(' ')
16
17
 
17
- const globalSections = await getGlobalSectionsData(previewData)
18
+ const [
19
+ globalSectionsPromise,
20
+ globalSectionsHeaderPromise,
21
+ globalSectionsFooterPromise,
22
+ ] = getGlobalSectionsData(previewData)
18
23
 
19
24
  if (storeConfig.cms.data) {
20
25
  const cmsData = JSON.parse(storeConfig.cms.data)
21
26
  const page = cmsData['search'][0]
22
27
  if (page) {
23
- const pageData = await getPage<SearchContentType>({
24
- contentType: 'search',
25
- documentId: page.documentId,
26
- versionId: page.versionId,
28
+ const [
29
+ pageData,
30
+ globalSections,
31
+ globalSectionsHeader,
32
+ globalSectionsFooter,
33
+ ] = await Promise.all([
34
+ getPage<SearchContentType>({
35
+ contentType: 'search',
36
+ documentId: page.documentId,
37
+ versionId: page.versionId,
38
+ }),
39
+ globalSectionsPromise,
40
+ globalSectionsHeaderPromise,
41
+ globalSectionsFooterPromise,
42
+ ])
43
+
44
+ const globalSectionsResult = injectGlobalSections({
45
+ globalSections,
46
+ globalSectionsHeader,
47
+ globalSectionsFooter,
27
48
  })
28
49
  return {
29
- props: { page: pageData, globalSections, searchTerm },
50
+ props: {
51
+ page: pageData,
52
+ globalSections: globalSectionsResult,
53
+ searchTerm,
54
+ },
30
55
  }
31
56
  }
32
57
  }
33
58
 
34
- const page = await getPage<SearchContentType>({
35
- ...(previewData?.contentType === 'search' ? previewData : null),
36
- contentType: 'search',
59
+ const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
60
+ await Promise.all([
61
+ getPage<SearchContentType>({
62
+ ...(previewData?.contentType === 'search' ? previewData : null),
63
+ contentType: 'search',
64
+ }),
65
+ globalSectionsPromise,
66
+ globalSectionsHeaderPromise,
67
+ globalSectionsFooterPromise,
68
+ ])
69
+
70
+ const globalSectionsResult = injectGlobalSections({
71
+ globalSections,
72
+ globalSectionsHeader,
73
+ globalSectionsFooter,
37
74
  })
38
75
 
39
76
  res.setHeader(
@@ -44,7 +81,7 @@ export const getServerSideProps: GetServerSideProps<
44
81
  return {
45
82
  props: {
46
83
  page,
47
- globalSections,
84
+ globalSections: globalSectionsResult,
48
85
  searchTerm,
49
86
  },
50
87
  }
@@ -1,11 +1,12 @@
1
+ import type { Locator } from '@vtex/client-cms'
2
+ import storeConfig from 'discovery.config'
1
3
  import type { GetStaticProps } from 'next'
2
4
  import {
3
5
  getGlobalSectionsData,
4
6
  type GlobalSectionsData,
5
7
  } from 'src/components/cms/GlobalSections'
6
- import { type SearchContentType, getPage } from 'src/server/cms'
7
- import type { Locator } from '@vtex/client-cms'
8
- import storeConfig from 'discovery.config'
8
+ import { getPage, type SearchContentType } from 'src/server/cms'
9
+ import { injectGlobalSections } from 'src/server/cms/global'
9
10
 
10
11
  export type SearchPageProps = {
11
12
  page: SearchContentType
@@ -13,8 +14,8 @@ export type SearchPageProps = {
13
14
  searchTerm?: string
14
15
  }
15
16
 
16
- /*
17
- Depending on the value of the storeConfig.experimental.enableSearchSSR flag, the function used will be getServerSideProps (./getServerSideProps).
17
+ /*
18
+ Depending on the value of the storeConfig.experimental.enableSearchSSR flag, the function used will be getServerSideProps (./getServerSideProps).
18
19
  Our CLI that does this process of converting from getStaticProps to getServerSideProps.
19
20
  */
20
21
  export const getStaticProps: GetStaticProps<
@@ -24,34 +25,66 @@ export const getStaticProps: GetStaticProps<
24
25
  > = async (context) => {
25
26
  const { previewData } = context
26
27
 
27
- const globalSections = await getGlobalSectionsData(previewData)
28
+ const [
29
+ globalSectionsPromise,
30
+ globalSectionsHeaderPromise,
31
+ globalSectionsFooterPromise,
32
+ ] = getGlobalSectionsData(previewData)
28
33
 
29
34
  if (storeConfig.cms.data) {
30
35
  const cmsData = JSON.parse(storeConfig.cms.data)
31
36
  const page = cmsData['search'][0]
32
37
 
33
38
  if (page) {
34
- const pageData = await getPage<SearchContentType>({
35
- contentType: 'search',
36
- documentId: page.documentId,
37
- versionId: page.versionId,
39
+ const [
40
+ pageData,
41
+ globalSections,
42
+ globalSectionsHeader,
43
+ globalSectionsFooter,
44
+ ] = await Promise.all([
45
+ getPage<SearchContentType>({
46
+ contentType: 'search',
47
+ documentId: page.documentId,
48
+ versionId: page.versionId,
49
+ }),
50
+ globalSectionsPromise,
51
+ globalSectionsHeaderPromise,
52
+ globalSectionsFooterPromise,
53
+ ])
54
+
55
+ const globalSectionsResult = injectGlobalSections({
56
+ globalSections,
57
+ globalSectionsHeader,
58
+ globalSectionsFooter,
38
59
  })
39
60
 
40
61
  return {
41
- props: { page: pageData, globalSections },
62
+ props: { page: pageData, globalSections: globalSectionsResult },
42
63
  }
43
64
  }
44
65
  }
45
66
 
46
- const page = await getPage<SearchContentType>({
47
- ...(previewData?.contentType === 'search' ? previewData : null),
48
- contentType: 'search',
67
+ const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
68
+ await Promise.all([
69
+ getPage<SearchContentType>({
70
+ ...(previewData?.contentType === 'search' ? previewData : null),
71
+ contentType: 'search',
72
+ }),
73
+ globalSectionsPromise,
74
+ globalSectionsHeaderPromise,
75
+ globalSectionsFooterPromise,
76
+ ])
77
+
78
+ const globalSectionsResult = injectGlobalSections({
79
+ globalSections,
80
+ globalSectionsHeader,
81
+ globalSectionsFooter,
49
82
  })
50
83
 
51
84
  return {
52
85
  props: {
53
86
  page,
54
- globalSections,
87
+ globalSections: globalSectionsResult,
55
88
  },
56
89
  }
57
90
  }
package/src/pages/404.tsx CHANGED
@@ -10,9 +10,10 @@ import {
10
10
  import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
11
11
  import RenderSections from 'src/components/cms/RenderSections'
12
12
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
13
- import PLUGINS_COMPONENTS from 'src/plugins'
14
13
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
14
+ import PLUGINS_COMPONENTS from 'src/plugins'
15
15
  import { type PageContentType, getPage } from 'src/server/cms'
16
+ import { injectGlobalSections } from 'src/server/cms/global'
16
17
 
17
18
  /* A list of components that can be used in the CMS. */
18
19
  const COMPONENTS: Record<string, ComponentType<any>> = {
@@ -56,16 +57,31 @@ export const getStaticProps: GetStaticProps<
56
57
  Record<string, string>,
57
58
  Locator
58
59
  > = async ({ previewData }) => {
59
- const [page, globalSections] = await Promise.all([
60
- getPage<PageContentType>({
61
- ...(previewData?.contentType === '404' && previewData),
62
- contentType: '404',
63
- }),
64
- getGlobalSectionsData(previewData),
65
- ])
60
+ const [
61
+ globalSectionsPromise,
62
+ globalSectionsHeaderPromise,
63
+ globalSectionsFooterPromise,
64
+ ] = getGlobalSectionsData(previewData)
65
+
66
+ const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
67
+ await Promise.all([
68
+ getPage<PageContentType>({
69
+ ...(previewData?.contentType === '404' && previewData),
70
+ contentType: '404',
71
+ }),
72
+ globalSectionsPromise,
73
+ globalSectionsHeaderPromise,
74
+ globalSectionsFooterPromise,
75
+ ])
76
+
77
+ const globalSectionsResult = injectGlobalSections({
78
+ globalSections,
79
+ globalSectionsHeader,
80
+ globalSectionsFooter,
81
+ })
66
82
 
67
83
  return {
68
- props: { page, globalSections },
84
+ props: { page, globalSections: globalSectionsResult },
69
85
  }
70
86
  }
71
87
 
package/src/pages/500.tsx CHANGED
@@ -10,9 +10,10 @@ import {
10
10
  import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
11
11
  import RenderSections from 'src/components/cms/RenderSections'
12
12
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
13
- import PLUGINS_COMPONENTS from 'src/plugins'
14
13
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
14
+ import PLUGINS_COMPONENTS from 'src/plugins'
15
15
  import { type PageContentType, getPage } from 'src/server/cms'
16
+ import { injectGlobalSections } from 'src/server/cms/global'
16
17
 
17
18
  /* A list of components that can be used in the CMS. */
18
19
  const COMPONENTS: Record<string, ComponentType<any>> = {
@@ -57,16 +58,31 @@ export const getStaticProps: GetStaticProps<
57
58
  Record<string, string>,
58
59
  Locator
59
60
  > = async ({ previewData }) => {
60
- const [page, globalSections] = await Promise.all([
61
- getPage<PageContentType>({
62
- ...(previewData?.contentType === '500' && previewData),
63
- contentType: '500',
64
- }),
65
- getGlobalSectionsData(previewData),
66
- ])
61
+ const [
62
+ globalSectionsPromise,
63
+ globalSectionsHeaderPromise,
64
+ globalSectionsFooterPromise,
65
+ ] = getGlobalSectionsData(previewData)
66
+
67
+ const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
68
+ await Promise.all([
69
+ getPage<PageContentType>({
70
+ ...(previewData?.contentType === '500' && previewData),
71
+ contentType: '500',
72
+ }),
73
+ globalSectionsPromise,
74
+ globalSectionsHeaderPromise,
75
+ globalSectionsFooterPromise,
76
+ ])
77
+
78
+ const globalSectionsResult = injectGlobalSections({
79
+ globalSections,
80
+ globalSectionsHeader,
81
+ globalSectionsFooter,
82
+ })
67
83
 
68
84
  return {
69
- props: { page, globalSections },
85
+ props: { page, globalSections: globalSectionsResult },
70
86
  }
71
87
  }
72
88
 
@@ -24,6 +24,7 @@ import ProductListingPage, {
24
24
  } from 'src/components/templates/ProductListingPage'
25
25
  import { getRedirect } from 'src/sdk/redirects'
26
26
  import type { PageContentType } from 'src/server/cms'
27
+ import { injectGlobalSections } from 'src/server/cms/global'
27
28
  import { getPLP, type PLPContentType } from 'src/server/cms/plp'
28
29
  import { getDynamicContent } from 'src/utils/dynamicContent'
29
30
 
@@ -102,23 +103,39 @@ export const getStaticProps: GetStaticProps<
102
103
  const slug = params?.slug.join('/') ?? ''
103
104
  const rewrites = (await storeConfig.rewrites?.()) ?? []
104
105
 
105
- const [landingPagePromise, globalSectionsPromise] = [
106
- getLandingPageBySlug(slug, previewData),
107
- getGlobalSectionsData(previewData),
108
- ]
106
+ const [
107
+ globalSectionsPromise,
108
+ globalSectionsHeaderPromise,
109
+ globalSectionsFooterPromise,
110
+ ] = getGlobalSectionsData(previewData)
111
+
112
+ const landingPagePromise = getLandingPageBySlug(slug, previewData)
109
113
 
110
114
  const landingPage = await landingPagePromise
111
115
 
112
116
  if (landingPage) {
113
- const [serverData, globalSections] = await Promise.all([
117
+ const [
118
+ serverData,
119
+ globalSections,
120
+ globalSectionsHeader,
121
+ globalSectionsFooter,
122
+ ] = await Promise.all([
114
123
  getDynamicContent({ pageType: slug }),
115
124
  globalSectionsPromise,
125
+ globalSectionsHeaderPromise,
126
+ globalSectionsFooterPromise,
116
127
  ])
117
128
 
129
+ const globalSectionsResult = injectGlobalSections({
130
+ globalSections,
131
+ globalSectionsHeader,
132
+ globalSectionsFooter,
133
+ })
134
+
118
135
  return {
119
136
  props: {
120
137
  page: landingPage,
121
- globalSections,
138
+ globalSections: globalSectionsResult,
122
139
  type: 'page',
123
140
  slug,
124
141
  serverData,
@@ -126,7 +143,13 @@ export const getStaticProps: GetStaticProps<
126
143
  }
127
144
  }
128
145
 
129
- const [{ data, errors = [] }, cmsPage, globalSections] = await Promise.all([
146
+ const [
147
+ { data, errors = [] },
148
+ cmsPage,
149
+ globalSections,
150
+ globalSectionsHeader,
151
+ globalSectionsFooter,
152
+ ] = await Promise.all([
130
153
  execute<
131
154
  ServerCollectionPageQueryQueryVariables,
132
155
  ServerCollectionPageQueryQuery
@@ -136,6 +159,8 @@ export const getStaticProps: GetStaticProps<
136
159
  }),
137
160
  getPLP(slug, previewData, rewrites),
138
161
  globalSectionsPromise,
162
+ globalSectionsHeaderPromise,
163
+ globalSectionsFooterPromise,
139
164
  ])
140
165
 
141
166
  const notFound = errors.find(isNotFoundError)
@@ -161,11 +186,17 @@ export const getStaticProps: GetStaticProps<
161
186
  throw errors[0]
162
187
  }
163
188
 
189
+ const globalSectionsResult = injectGlobalSections({
190
+ globalSections,
191
+ globalSectionsHeader,
192
+ globalSectionsFooter,
193
+ })
194
+
164
195
  return {
165
196
  props: {
166
197
  data,
167
198
  page: cmsPage,
168
- globalSections,
199
+ globalSections: globalSectionsResult,
169
200
  type: 'plp',
170
201
  key: slug,
171
202
  },