@faststore/core 3.23.0 → 3.24.1

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 (80) 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/5656.js +9 -0
  14. package/.next/server/chunks/{9622.js → 7355.js} +3 -3
  15. package/.next/server/middleware-build-manifest.js +1 -1
  16. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  17. package/.next/server/pages/404.js +1 -1
  18. package/.next/server/pages/404.js.nft.json +1 -1
  19. package/.next/server/pages/500.js +1 -1
  20. package/.next/server/pages/500.js.nft.json +1 -1
  21. package/.next/server/pages/[...slug].js +1 -1
  22. package/.next/server/pages/[...slug].js.nft.json +1 -1
  23. package/.next/server/pages/[slug]/p.js +1 -1
  24. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  25. package/.next/server/pages/_app.js.nft.json +1 -1
  26. package/.next/server/pages/_document.js.nft.json +1 -1
  27. package/.next/server/pages/_error.js.nft.json +1 -1
  28. package/.next/server/pages/account.js +1 -1
  29. package/.next/server/pages/account.js.nft.json +1 -1
  30. package/.next/server/pages/api/graphql.js +1 -1
  31. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  32. package/.next/server/pages/api/health/live.js.nft.json +1 -1
  33. package/.next/server/pages/api/health/ready.js.nft.json +1 -1
  34. package/.next/server/pages/api/preview.js.nft.json +1 -1
  35. package/.next/server/pages/checkout.js +1 -1
  36. package/.next/server/pages/checkout.js.nft.json +1 -1
  37. package/.next/server/pages/en-US/404.html +2 -2
  38. package/.next/server/pages/en-US/500.html +2 -2
  39. package/.next/server/pages/en-US/account.html +2 -2
  40. package/.next/server/pages/en-US/checkout.html +2 -2
  41. package/.next/server/pages/en-US/login.html +2 -2
  42. package/.next/server/pages/en-US/s.html +2 -2
  43. package/.next/server/pages/en-US.html +2 -2
  44. package/.next/server/pages/index.js +1 -1
  45. package/.next/server/pages/index.js.nft.json +1 -1
  46. package/.next/server/pages/login.js +1 -1
  47. package/.next/server/pages/login.js.nft.json +1 -1
  48. package/.next/server/pages/s.js +1 -1
  49. package/.next/server/pages/s.js.nft.json +1 -1
  50. package/.next/static/chunks/9180.0662762fa7ceac5d.js +1 -0
  51. package/.next/static/chunks/pages/{404-3d151353c4e53a04.js → 404-32bb6fa89ab66aca.js} +1 -1
  52. package/.next/static/chunks/pages/{500-b7900a231cd5a12d.js → 500-eb359aa3bffe64a6.js} +1 -1
  53. package/.next/static/chunks/pages/{login-03e155dd4f803d5d.js → login-6678b657c8c13867.js} +1 -1
  54. package/.next/static/chunks/{webpack-73f875a3fea96a4a.js → webpack-bd7f68a5f4827cb0.js} +1 -1
  55. package/.next/static/{frJ1Rp8XRqHORhBpoOnih → qaRgicHUu7U8273um8QDo}/_buildManifest.js +1 -1
  56. package/.next/trace +121 -121
  57. package/.turbo/turbo-build.log +8 -8
  58. package/.turbo/turbo-test.log +8 -7
  59. package/CHANGELOG.md +12 -0
  60. package/cms/faststore/content-types.json +14 -0
  61. package/package.json +2 -2
  62. package/src/components/cms/GlobalSections.tsx +28 -7
  63. package/src/experimental/searchServerSideFunctions/getServerSideProps.ts +49 -12
  64. package/src/experimental/searchServerSideFunctions/getStaticProps.ts +48 -15
  65. package/src/pages/404.tsx +25 -9
  66. package/src/pages/500.tsx +25 -9
  67. package/src/pages/[...slug].tsx +39 -8
  68. package/src/pages/[slug]/p.tsx +24 -3
  69. package/src/pages/account.tsx +20 -2
  70. package/src/pages/checkout.tsx +20 -2
  71. package/src/pages/index.tsx +24 -3
  72. package/src/pages/login.tsx +25 -9
  73. package/src/sdk/error/ChildrenSectionNotFoundError/ChildrenSectionNotFoundError.ts +6 -0
  74. package/src/sdk/error/ChildrenSectionNotFoundError/index.ts +1 -0
  75. package/src/server/cms/global.ts +38 -0
  76. package/src/server/cms/index.ts +1 -5
  77. package/test/server/cms/global.test.ts +86 -0
  78. package/.next/server/chunks/7816.js +0 -9
  79. package/.next/static/chunks/9180.ca246b121565be34.js +0 -1
  80. /package/.next/static/{frJ1Rp8XRqHORhBpoOnih → qaRgicHUu7U8273um8QDo}/_ssgManifest.js +0 -0
@@ -1,23 +1,23 @@
1
1
 
2
- > @faststore/core@3.22.3 prebuild /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.24.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.3 partytown /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@3.24.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.3 generate /home/runner/work/faststore/faststore/packages/core
11
+ > @faststore/core@3.24.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.3 generate:schema /home/runner/work/faststore/faststore/packages/core
15
+ > @faststore/core@3.24.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.3 generate:codegen /home/runner/work/faststore/faststore/packages/core
20
+ > @faststore/core@3.24.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.3 format:generated /home/runner/work/faststore/faststore/packages/core
40
+ > @faststore/core@3.24.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.3 build /home/runner/work/faststore/faststore/packages/core
44
+ > @faststore/core@3.24.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
@@ -90,7 +90,7 @@ Route (pages) Size First Load JS
90
90
  ├ chunks/framework-807b0f81cbc129f0.js 45.4 kB
91
91
  ├ chunks/main-1617ca75abfe1b79.js 33.1 kB
92
92
  ├ chunks/pages/_app-859f97f9c8a57799.js 10.2 kB
93
- ├ chunks/webpack-73f875a3fea96a4a.js 3.58 kB
93
+ ├ chunks/webpack-bd7f68a5f4827cb0.js 3.58 kB
94
94
  └ css/2eafb8997a3946dc.css 3.07 kB
95
95
 
96
96
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1,13 +1,14 @@
1
1
 
2
- > @faststore/core@3.22.3 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.24.0 test /home/runner/work/faststore/faststore/packages/core
3
3
  > jest
4
4
 
5
- PASS test/server/cms/index.test.ts (28.751 s)
6
- PASS test/utils/multipleTemplates.test.ts (29.113 s)
7
- PASS test/server/index.test.ts (33.854 s)
5
+ PASS test/utils/multipleTemplates.test.ts (29.24 s)
6
+ PASS test/server/cms/global.test.ts (29.462 s)
7
+ PASS test/server/cms/index.test.ts
8
+ PASS test/server/index.test.ts (34.523 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.849 s
13
+ Time: 35.733 s
13
14
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
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.1](https://github.com/vtex/faststore/compare/v3.24.0...v3.24.1) (2025-02-26)
7
+
8
+ ### Bug Fixes
9
+
10
+ - removes MissingContentError checks in getPage ([#2704](https://github.com/vtex/faststore/issues/2704)) ([0c75ea0](https://github.com/vtex/faststore/commit/0c75ea05b0d3c8ee62daa988c80152ba1464755c))
11
+
12
+ # [3.24.0](https://github.com/vtex/faststore/compare/v3.23.0...v3.24.0) (2025-02-26)
13
+
14
+ ### Features
15
+
16
+ - Multiple global content types ([#2668](https://github.com/vtex/faststore/issues/2668)) ([8555310](https://github.com/vtex/faststore/commit/85553101b1d8f3ec510259007ff1d594ec33c338))
17
+
6
18
  # [3.23.0](https://github.com/vtex/faststore/compare/v3.22.3...v3.23.0) (2025-02-26)
7
19
 
8
20
  **Note:** Version bump only for package @faststore/core
@@ -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.23.0",
3
+ "version": "3.24.1",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -104,5 +104,5 @@
104
104
  "ts-jest": "29.1.1",
105
105
  "typescript": "5.3.2"
106
106
  },
107
- "gitHead": "1ef5f7a26a231da6fe3cfefd1937e6b4ed380a13"
107
+ "gitHead": "2bc0845e5cae764416a12f62d015a41b72900081"
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
  },
@@ -35,6 +35,7 @@ import {
35
35
  import { getOfferUrl, useOffer } from 'src/sdk/offer'
36
36
  import PageProvider, { type PDPContext } from 'src/sdk/overrides/PageProvider'
37
37
  import { useProductQuery } from 'src/sdk/product/useProductQuery'
38
+ import { injectGlobalSections } from 'src/server/cms/global'
38
39
  import { getPDP, type PDPContentType } from 'src/server/cms/pdp'
39
40
 
40
41
  type StoreConfig = typeof storeConfig & {
@@ -260,12 +261,26 @@ export const getStaticProps: GetStaticProps<
260
261
  Locator
261
262
  > = async ({ params, previewData }) => {
262
263
  const slug = params?.slug ?? ''
263
- const [searchResult, globalSections] = await Promise.all([
264
+
265
+ const [
266
+ globalSectionsPromise,
267
+ globalSectionsHeaderPromise,
268
+ globalSectionsFooterPromise,
269
+ ] = getGlobalSectionsData(previewData)
270
+
271
+ const [
272
+ searchResult,
273
+ globalSections,
274
+ globalSectionsHeader,
275
+ globalSectionsFooter,
276
+ ] = await Promise.all([
264
277
  execute<ServerProductQueryQueryVariables, ServerProductQueryQuery>({
265
278
  variables: { locator: [{ key: 'slug', value: slug }] },
266
279
  operation: query,
267
280
  }),
268
- getGlobalSectionsData(previewData),
281
+ globalSectionsPromise,
282
+ globalSectionsHeaderPromise,
283
+ globalSectionsFooterPromise,
269
284
  ])
270
285
 
271
286
  const { data, errors = [] } = searchResult
@@ -305,13 +320,19 @@ export const getStaticProps: GetStaticProps<
305
320
  url: canonical,
306
321
  }
307
322
 
323
+ const globalSectionsResult = injectGlobalSections({
324
+ globalSections,
325
+ globalSectionsHeader,
326
+ globalSectionsFooter,
327
+ })
328
+
308
329
  return {
309
330
  props: {
310
331
  data,
311
332
  ...cmsPage,
312
333
  meta,
313
334
  offers,
314
- globalSections,
335
+ globalSections: globalSectionsResult,
315
336
  key: seo.canonical,
316
337
  },
317
338
  revalidate: (storeConfig as StoreConfig).experimental.revalidate ?? false,