@faststore/core 3.0.152 → 3.0.154

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 (232) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +82 -88
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-minimal-server.js.nft.json +1 -1
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.js +1 -1
  13. package/.next/prerender-manifest.json +1 -1
  14. package/.next/react-loadable-manifest.json +214 -48
  15. package/.next/routes-manifest.json +1 -1
  16. package/.next/server/chunks/1844.js +1 -1
  17. package/.next/server/chunks/319.js +1 -0
  18. package/.next/server/chunks/3199.js +1 -0
  19. package/.next/server/chunks/4350.js +1 -0
  20. package/.next/server/chunks/5156.js +1 -0
  21. package/.next/server/chunks/5380.js +1 -0
  22. package/.next/server/chunks/5476.js +1 -0
  23. package/.next/server/chunks/5671.js +1 -1
  24. package/.next/server/chunks/5754.js +9 -0
  25. package/.next/server/chunks/6414.js +1 -0
  26. package/.next/server/chunks/8096.js +1 -1
  27. package/.next/server/chunks/8419.js +1 -0
  28. package/.next/server/chunks/8640.js +1 -0
  29. package/.next/server/chunks/8737.js +1 -0
  30. package/.next/server/chunks/9088.js +1 -1
  31. package/.next/server/chunks/9369.js +1 -0
  32. package/.next/server/chunks/9572.js +307 -0
  33. package/.next/server/chunks/983.js +1 -0
  34. package/.next/server/chunks/ScrollToTopButton.js +1 -0
  35. package/.next/server/chunks/UIBannerText.js +1 -1
  36. package/.next/server/middleware-build-manifest.js +1 -1
  37. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  38. package/.next/server/pages/404.js +1 -1
  39. package/.next/server/pages/404.js.nft.json +1 -1
  40. package/.next/server/pages/500.js +1 -1
  41. package/.next/server/pages/500.js.nft.json +1 -1
  42. package/.next/server/pages/[...slug].js +1 -1
  43. package/.next/server/pages/[...slug].js.nft.json +1 -1
  44. package/.next/server/pages/[slug]/p.js +1 -1
  45. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  46. package/.next/server/pages/_app.js.nft.json +1 -1
  47. package/.next/server/pages/_document.js.nft.json +1 -1
  48. package/.next/server/pages/_error.js.nft.json +1 -1
  49. package/.next/server/pages/account.js +1 -1
  50. package/.next/server/pages/account.js.nft.json +1 -1
  51. package/.next/server/pages/api/graphql.js +1 -1
  52. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  53. package/.next/server/pages/api/health/live.js.nft.json +1 -1
  54. package/.next/server/pages/api/health/ready.js.nft.json +1 -1
  55. package/.next/server/pages/api/preview.js +1 -1
  56. package/.next/server/pages/api/preview.js.nft.json +1 -1
  57. package/.next/server/pages/checkout.js +1 -1
  58. package/.next/server/pages/checkout.js.nft.json +1 -1
  59. package/.next/server/pages/en-US/404.html +1 -1
  60. package/.next/server/pages/en-US/404.json +1 -1
  61. package/.next/server/pages/en-US/500.html +1 -1
  62. package/.next/server/pages/en-US/500.json +1 -1
  63. package/.next/server/pages/en-US/account.html +1 -1
  64. package/.next/server/pages/en-US/account.json +1 -1
  65. package/.next/server/pages/en-US/checkout.html +1 -1
  66. package/.next/server/pages/en-US/checkout.json +1 -1
  67. package/.next/server/pages/en-US/login.html +1 -1
  68. package/.next/server/pages/en-US/login.json +1 -1
  69. package/.next/server/pages/en-US/s.html +1 -1
  70. package/.next/server/pages/en-US/s.json +1 -1
  71. package/.next/server/pages/en-US.html +2 -11
  72. package/.next/server/pages/en-US.json +1 -1
  73. package/.next/server/pages/index.js +1 -1
  74. package/.next/server/pages/index.js.nft.json +1 -1
  75. package/.next/server/pages/login.js +1 -1
  76. package/.next/server/pages/login.js.nft.json +1 -1
  77. package/.next/server/pages/s.js +1 -1
  78. package/.next/server/pages/s.js.nft.json +1 -1
  79. package/.next/server/pages-manifest.json +1 -1
  80. package/.next/server/webpack-runtime.js +1 -1
  81. package/.next/static/SfomoT7cCMNxtcr8yWFzF/_buildManifest.js +1 -0
  82. package/.next/static/chunks/1153.d7522522b6c917ed.js +1 -0
  83. package/.next/static/chunks/1550-f05e702b3204bd0a.js +1 -0
  84. package/.next/static/chunks/1552.a7758d4b2464351a.js +1 -0
  85. package/.next/static/chunks/1770.b0a7b096fe1d1bb2.js +1 -0
  86. package/.next/static/chunks/1774.85dc251aa39a517b.js +1 -0
  87. package/.next/static/chunks/2032.0826fda8cd80138d.js +1 -0
  88. package/.next/static/chunks/2388.908db499afc2082a.js +1 -0
  89. package/.next/static/chunks/2552.b245748eb0e40257.js +1 -0
  90. package/.next/static/chunks/3202.2bdeba847ce9ecd4.js +1 -0
  91. package/.next/static/chunks/3523.9c4d94172a1336ac.js +1 -0
  92. package/.next/static/chunks/3666.107f6d709e2d3b2c.js +1 -0
  93. package/.next/static/chunks/459-e4b75fb35a56e812.js +1 -0
  94. package/.next/static/chunks/5156.fe20405ee7a0d2d5.js +1 -0
  95. package/.next/static/chunks/5217.350e250227ef3657.js +1 -0
  96. package/.next/static/chunks/5380.955177408ea25915.js +1 -0
  97. package/.next/static/chunks/5484.50796e8843ec9dad.js +1 -0
  98. package/.next/static/chunks/5810.470a769e37e4b13b.js +1 -0
  99. package/.next/static/chunks/5997.8b2a914748263bb7.js +1 -0
  100. package/.next/static/chunks/6379-1578190b254c09a6.js +1 -0
  101. package/.next/static/chunks/6941-6223429b182b7109.js +33 -0
  102. package/.next/static/chunks/6999-7b2e114edc42cc1c.js +1 -0
  103. package/.next/static/chunks/7195.fb3e46b248b339d1.js +1 -0
  104. package/.next/static/chunks/8501.c65e0e689232daaf.js +1 -0
  105. package/.next/static/chunks/8857.0ff8f6604fb061a8.js +1 -0
  106. package/.next/static/chunks/9463.6f5675e44c925bfc.js +1 -0
  107. package/.next/static/chunks/983.3808cb829b3a4ec9.js +1 -0
  108. package/.next/static/chunks/BannerNewsletter.0b61ee5e562a55e0.js +1 -0
  109. package/.next/static/chunks/BannerText.a10d4f428fc5cd97.js +1 -0
  110. package/.next/static/chunks/ButtonSignIn.530066e6a0aaaa4b.js +1 -0
  111. package/.next/static/chunks/CartItem.64f56e23e94f577b.js +1 -0
  112. package/.next/static/chunks/CartSidebar.dfa8017080b88d46.js +1 -0
  113. package/.next/static/chunks/EmptyCart.335d05fe570a1b28.js +1 -0
  114. package/.next/static/chunks/Footer.c0816f0c74d7e24b.js +1 -0
  115. package/.next/static/chunks/Gift.a189921eb7c7a1a8.js +1 -0
  116. package/.next/static/chunks/Newsletter.7a07fe93f98e2922.js +1 -0
  117. package/.next/static/chunks/OrderSummary.2b7aae72c78d68ae.js +1 -0
  118. package/.next/static/chunks/ProductShelf.44b90c6f4e1c13d6.js +1 -0
  119. package/.next/static/chunks/ProductTiles.b3c7bd3a52226529.js +1 -0
  120. package/.next/static/chunks/RegionModal.23513fc5245a511f.js +1 -0
  121. package/.next/static/chunks/ScrollToTopButton.1fd39c18569afe69.js +1 -0
  122. package/.next/static/chunks/Toast.8635143b7896eb54.js +1 -0
  123. package/.next/static/chunks/UIBannerText.ac22c6843ac720b8.js +1 -0
  124. package/.next/static/chunks/UIButton.c6beeae8a8d0d6f3.js +1 -0
  125. package/.next/static/chunks/UIToast.a3b2b8fb137a7e55.js +1 -0
  126. package/.next/static/chunks/{framework-8e279965036b6169.js → framework-12a146e94cfcf7c4.js} +2 -2
  127. package/.next/static/chunks/main-209ac4974b020af1.js +1 -0
  128. package/.next/static/chunks/pages/404-358f6795222bf991.js +1 -0
  129. package/.next/static/chunks/pages/500-7adc48c3231ccee1.js +1 -0
  130. package/.next/static/chunks/pages/[...slug]-dcd9dbc989fa6d96.js +1 -0
  131. package/.next/static/chunks/pages/[slug]/p-eee2b539c749f442.js +1 -0
  132. package/.next/static/chunks/pages/_app-e419b2062065ccf0.js +1 -0
  133. package/.next/static/chunks/pages/_error-85cabf0d7a5ea2f2.js +1 -0
  134. package/.next/static/chunks/pages/account-9db0ef5c4174c7dd.js +1 -0
  135. package/.next/static/chunks/pages/checkout-abaa6374ae946641.js +1 -0
  136. package/.next/static/chunks/pages/index-8c1d9f19fd83e58b.js +1 -0
  137. package/.next/static/chunks/pages/login-8d2eb8db226d6363.js +1 -0
  138. package/.next/static/chunks/pages/s-67ecf818f7c63b16.js +1 -0
  139. package/.next/static/chunks/webpack-909c48392196dcdf.js +1 -0
  140. package/.next/static/css/083dc2a5b0de2439.css +1 -0
  141. package/.next/static/css/18e4be87b97035da.css +1 -0
  142. package/.next/static/css/210f14f5aba4cccd.css +1 -0
  143. package/.next/static/css/22fa0a502d499a62.css +1 -0
  144. package/.next/static/css/326d9de401ed8b48.css +1 -0
  145. package/.next/static/css/339c61e31dc962ed.css +1 -0
  146. package/.next/static/css/5273202f7c5e5ec1.css +1 -0
  147. package/.next/static/css/865e30903caadb79.css +1 -0
  148. package/.next/static/css/{e47f1a002bdcf76f.css → 936c65069d608087.css} +1 -1
  149. package/.next/static/css/93d239c461485bdf.css +1 -0
  150. package/.next/static/css/9718991cd57978e9.css +1 -0
  151. package/.next/static/css/b1806cbafd0c1f81.css +1 -0
  152. package/.next/static/css/bd9313ce4313a00a.css +1 -0
  153. package/.next/static/css/cba7600898edb684.css +1 -0
  154. package/.next/trace +97 -98
  155. package/.turbo/turbo-build.log +23 -23
  156. package/.turbo/turbo-lint.log +1 -1
  157. package/.turbo/turbo-test.log +5 -5
  158. package/package.json +2 -2
  159. package/src/components/cms/GlobalSections.tsx +0 -37
  160. package/src/components/cms/RenderSections.tsx +25 -17
  161. package/src/components/cms/home/Components.ts +7 -3
  162. package/src/components/cms/plp/Components.ts +59 -0
  163. package/src/components/cms/search/Components.ts +68 -0
  164. package/src/components/sections/ProductShelf/DefaultComponents.ts +17 -3
  165. package/src/components/templates/LandingPage/LandingPage.tsx +9 -1
  166. package/src/components/templates/ProductListingPage/ProductListing.tsx +25 -31
  167. package/src/components/templates/ProductListingPage/ProductListingPage.tsx +7 -1
  168. package/src/components/templates/SearchPage/SearchPage.tsx +13 -30
  169. package/src/components/templates/SearchPage/SearchWrapper.tsx +3 -0
  170. package/src/components/ui/ProductShelf/ProductShelf.tsx +7 -1
  171. package/src/pages/404.tsx +11 -5
  172. package/src/pages/500.tsx +11 -5
  173. package/src/pages/[...slug].tsx +31 -12
  174. package/src/pages/[slug]/p.tsx +10 -4
  175. package/src/pages/account.tsx +20 -8
  176. package/src/pages/api/preview.ts +33 -11
  177. package/src/pages/checkout.tsx +21 -7
  178. package/src/pages/index.tsx +9 -23
  179. package/src/pages/login.tsx +14 -8
  180. package/src/pages/s.tsx +34 -35
  181. package/.next/server/chunks/1972.js +0 -1
  182. package/.next/server/chunks/350.js +0 -1
  183. package/.next/server/chunks/5070.js +0 -1
  184. package/.next/server/chunks/5771.js +0 -1
  185. package/.next/server/chunks/6153.js +0 -1
  186. package/.next/server/chunks/6604.js +0 -9
  187. package/.next/server/chunks/9646.js +0 -307
  188. package/.next/static/03UTa7YuWpYhZyEUa_cAu/_buildManifest.js +0 -1
  189. package/.next/static/chunks/135.e5b151734fa29f99.js +0 -1
  190. package/.next/static/chunks/153.70d524f369fef82b.js +0 -1
  191. package/.next/static/chunks/16.f4ecc14d79dc118b.js +0 -1
  192. package/.next/static/chunks/195.5f46b2d90f69ddfc.js +0 -1
  193. package/.next/static/chunks/202.2a784500752e6a56.js +0 -1
  194. package/.next/static/chunks/217.01bc0ad07edd6f1b.js +0 -1
  195. package/.next/static/chunks/343.d1c1e47ba6dfb4d9.js +0 -1
  196. package/.next/static/chunks/388.0b1a49b31ff12af9.js +0 -1
  197. package/.next/static/chunks/484.755bc4e4fb57ebb9.js +0 -1
  198. package/.next/static/chunks/523.fe333b7a44e82888.js +0 -1
  199. package/.next/static/chunks/568.50cb2fbb158c2a19.js +0 -1
  200. package/.next/static/chunks/617.0a2a7e39a7f3d4cc.js +0 -1
  201. package/.next/static/chunks/707-6818d9951a83f35f.js +0 -1
  202. package/.next/static/chunks/721-4610a9b937a1b5e9.js +0 -1
  203. package/.next/static/chunks/844.dd528a0bb7646dd6.js +0 -1
  204. package/.next/static/chunks/857.d2299cfe995af21d.js +0 -1
  205. package/.next/static/chunks/941-cee2b9776c3d2607.js +0 -33
  206. package/.next/static/chunks/973-d39dc88330d50aca.js +0 -1
  207. package/.next/static/chunks/ButtonSignIn.7c4c1355603b23bb.js +0 -1
  208. package/.next/static/chunks/CartItem.1b93d9b5f36a1120.js +0 -1
  209. package/.next/static/chunks/EmptyCart.a48b5bfb30ee09f0.js +0 -1
  210. package/.next/static/chunks/Gift.9a645d71d393dd98.js +0 -1
  211. package/.next/static/chunks/OrderSummary.637b2fff8f2574e1.js +0 -1
  212. package/.next/static/chunks/Toast.41ed93193046b5a5.js +0 -1
  213. package/.next/static/chunks/UIBannerText.4e11acdb3624808c.js +0 -1
  214. package/.next/static/chunks/UIToast.a17cb67e284572a7.js +0 -1
  215. package/.next/static/chunks/main-029f1328cfee9686.js +0 -1
  216. package/.next/static/chunks/pages/404-8428a5072b126db7.js +0 -1
  217. package/.next/static/chunks/pages/500-0f7529c8c8b90253.js +0 -1
  218. package/.next/static/chunks/pages/[...slug]-0db45ebf94081661.js +0 -1
  219. package/.next/static/chunks/pages/[slug]/p-1433a856605b917b.js +0 -1
  220. package/.next/static/chunks/pages/_app-cb1c3a94f987c5c8.js +0 -1
  221. package/.next/static/chunks/pages/_error-fbf331a03642b495.js +0 -1
  222. package/.next/static/chunks/pages/account-c0db07a5e90d1ee0.js +0 -1
  223. package/.next/static/chunks/pages/checkout-a751fc8e1dcb5285.js +0 -1
  224. package/.next/static/chunks/pages/index-a4ffe552b1b4a4a6.js +0 -1
  225. package/.next/static/chunks/pages/login-93bbc8089da5ce4a.js +0 -1
  226. package/.next/static/chunks/pages/s-7ad120ac3e73cbea.js +0 -1
  227. package/.next/static/chunks/webpack-ab89187244c136e9.js +0 -1
  228. package/.next/static/css/16d438c29387e6ad.css +0 -1
  229. package/.next/static/css/1ad39dcb52269ada.css +0 -1
  230. package/.next/static/css/9b6bba2472d272ec.css +0 -1
  231. package/.next/static/css/e8d8f9a77767c4b3.css +0 -1
  232. /package/.next/static/{03UTa7YuWpYhZyEUa_cAu → SfomoT7cCMNxtcr8yWFzF}/_ssgManifest.js +0 -0
@@ -26,12 +26,14 @@ export type SearchWrapperProps = {
26
26
  itemsPerPage: number
27
27
  searchContentType: SearchContentType
28
28
  serverData: SearchPageContextType
29
+ globalSections?: Array<{ name: string; data: any }>
29
30
  }
30
31
 
31
32
  export default function SearchWrapper({
32
33
  itemsPerPage,
33
34
  searchContentType,
34
35
  serverData,
36
+ globalSections,
35
37
  }: SearchWrapperProps) {
36
38
  const router = useRouter()
37
39
  const {
@@ -64,6 +66,7 @@ export default function SearchWrapper({
64
66
  <SearchPage
65
67
  page={searchContentType}
66
68
  data={{ ...serverData, ...pageProductGalleryData }}
69
+ globalSections={globalSections}
67
70
  />
68
71
  )
69
72
  }
@@ -1,11 +1,17 @@
1
+ import dynamic from 'next/dynamic'
1
2
  import { useEffect, useId, useRef } from 'react'
2
3
 
3
- import ProductShelfSkeleton from 'src/components/skeletons/ProductShelfSkeleton'
4
4
  import { useViewItemListEvent } from 'src/sdk/analytics/hooks/useViewItemListEvent'
5
5
  import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
6
6
  import { useProductsQuery } from 'src/sdk/product/useProductsQuery'
7
7
  import { textToKebabCase } from 'src/utils/utilities'
8
8
 
9
+ const ProductShelfSkeleton = dynamic(
10
+ () =>
11
+ /* webpackChunkName: "ProductShelfSkeleton" */
12
+ import('src/components/skeletons/ProductShelfSkeleton')
13
+ )
14
+
9
15
  type Sort =
10
16
  | 'discount_desc'
11
17
  | 'name_asc'
package/src/pages/404.tsx CHANGED
@@ -1,12 +1,13 @@
1
1
  import { Locator } from '@vtex/client-cms'
2
2
  import { GetStaticProps } from 'next'
3
3
  import { NextSeo } from 'next-seo'
4
- import GlobalSections, {
4
+ import type { ComponentType } from 'react'
5
+ import {
5
6
  GlobalSectionsData,
6
7
  getGlobalSectionsData,
7
8
  } from 'src/components/cms/GlobalSections'
8
- import type { ComponentType } from 'react'
9
9
 
10
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
10
11
  import RenderSections from 'src/components/cms/RenderSections'
11
12
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
12
13
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
@@ -14,6 +15,7 @@ import { PageContentType, getPage } from 'src/server/cms'
14
15
 
15
16
  /* A list of components that can be used in the CMS. */
16
17
  const COMPONENTS: Record<string, ComponentType<any>> = {
18
+ ...GLOBAL_COMPONENTS,
17
19
  EmptyState,
18
20
  ...CUSTOM_COMPONENTS,
19
21
  }
@@ -25,7 +27,7 @@ type Props = {
25
27
 
26
28
  function Page({ page: { sections }, globalSections }: Props) {
27
29
  return (
28
- <GlobalSections {...globalSections}>
30
+ <>
29
31
  <NextSeo noindex nofollow />
30
32
  {/*
31
33
  WARNING: Do not import or render components from any
@@ -38,8 +40,12 @@ function Page({ page: { sections }, globalSections }: Props) {
38
40
  If needed, wrap your component in a <Section /> component
39
41
  (not the HTML tag) before rendering it here.
40
42
  */}
41
- <RenderSections sections={sections} components={COMPONENTS} />
42
- </GlobalSections>
43
+ <RenderSections
44
+ sections={sections}
45
+ globalSections={globalSections.sections}
46
+ components={COMPONENTS}
47
+ />
48
+ </>
43
49
  )
44
50
  }
45
51
 
package/src/pages/500.tsx CHANGED
@@ -1,12 +1,13 @@
1
1
  import { Locator } from '@vtex/client-cms'
2
2
  import { GetStaticProps } from 'next'
3
3
  import { NextSeo } from 'next-seo'
4
- import GlobalSections, {
4
+ import type { ComponentType } from 'react'
5
+ import {
5
6
  GlobalSectionsData,
6
7
  getGlobalSectionsData,
7
8
  } from 'src/components/cms/GlobalSections'
8
- import type { ComponentType } from 'react'
9
9
 
10
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
10
11
  import RenderSections from 'src/components/cms/RenderSections'
11
12
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
12
13
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
@@ -14,6 +15,7 @@ import { PageContentType, getPage } from 'src/server/cms'
14
15
 
15
16
  /* A list of components that can be used in the CMS. */
16
17
  const COMPONENTS: Record<string, ComponentType<any>> = {
18
+ ...GLOBAL_COMPONENTS,
17
19
  EmptyState,
18
20
  ...CUSTOM_COMPONENTS,
19
21
  }
@@ -25,7 +27,7 @@ type Props = {
25
27
 
26
28
  function Page({ page: { sections }, globalSections }: Props) {
27
29
  return (
28
- <GlobalSections {...globalSections}>
30
+ <>
29
31
  <NextSeo noindex nofollow />
30
32
 
31
33
  {/*
@@ -39,8 +41,12 @@ function Page({ page: { sections }, globalSections }: Props) {
39
41
  If needed, wrap your component in a <Section /> component
40
42
  (not the HTML tag) before rendering it here.
41
43
  */}
42
- <RenderSections sections={sections} components={COMPONENTS} />
43
- </GlobalSections>
44
+ <RenderSections
45
+ sections={sections}
46
+ globalSections={globalSections.sections}
47
+ components={COMPONENTS}
48
+ />
49
+ </>
44
50
  )
45
51
  }
46
52
 
@@ -10,11 +10,12 @@ import type {
10
10
  import { execute } from 'src/server'
11
11
 
12
12
  import { Locator } from '@vtex/client-cms'
13
- import GlobalSections, {
13
+ import dynamic from 'next/dynamic'
14
+ import {
14
15
  getGlobalSectionsData,
15
16
  GlobalSectionsData,
16
17
  } from 'src/components/cms/GlobalSections'
17
- import LandingPage, {
18
+ import {
18
19
  getLandingPageBySlug,
19
20
  LandingPageProps,
20
21
  } from 'src/components/templates/LandingPage'
@@ -25,6 +26,10 @@ import { PageContentType } from 'src/server/cms'
25
26
  import { getPLP, PLPContentType } from 'src/server/cms/plp'
26
27
  import { getDynamicContent } from 'src/utils/dynamicContent'
27
28
 
29
+ const LandingPage = dynamic(
30
+ () => import('src/components/templates/LandingPage')
31
+ )
32
+
28
33
  type BaseProps = {
29
34
  globalSections: GlobalSectionsData
30
35
  }
@@ -46,12 +51,20 @@ type Props = BaseProps &
46
51
 
47
52
  function Page({ globalSections, type, ...otherProps }: Props) {
48
53
  return (
49
- <GlobalSections {...globalSections}>
54
+ <>
50
55
  {type === 'plp' && (
51
- <ProductListingPage {...(otherProps as ProductListingPageProps)} />
56
+ <ProductListingPage
57
+ globalSections={globalSections.sections}
58
+ {...(otherProps as ProductListingPageProps)}
59
+ />
60
+ )}
61
+ {type === 'page' && (
62
+ <LandingPage
63
+ globalSections={globalSections.sections}
64
+ {...(otherProps as LandingPageProps)}
65
+ />
52
66
  )}
53
- {type === 'page' && <LandingPage {...(otherProps as LandingPageProps)} />}
54
- </GlobalSections>
67
+ </>
55
68
  )
56
69
  }
57
70
 
@@ -93,13 +106,18 @@ export const getStaticProps: GetStaticProps<
93
106
  getGlobalSectionsData(previewData),
94
107
  ]
95
108
 
96
- if (await landingPagePromise) {
97
- const serverData = await getDynamicContent({ pageType: slug })
109
+ const landingPage = await landingPagePromise
110
+
111
+ if (landingPage) {
112
+ const [serverData, globalSections] = await Promise.all([
113
+ getDynamicContent({ pageType: slug }),
114
+ globalSectionsPromise,
115
+ ])
98
116
 
99
117
  return {
100
118
  props: {
101
- page: await landingPagePromise,
102
- globalSections: await globalSectionsPromise,
119
+ page: landingPage,
120
+ globalSections,
103
121
  type: 'page',
104
122
  slug,
105
123
  serverData,
@@ -107,7 +125,7 @@ export const getStaticProps: GetStaticProps<
107
125
  }
108
126
  }
109
127
 
110
- const [{ data, errors = [] }, cmsPage] = await Promise.all([
128
+ const [{ data, errors = [] }, cmsPage, globalSections] = await Promise.all([
111
129
  execute<
112
130
  ServerCollectionPageQueryQueryVariables,
113
131
  ServerCollectionPageQueryQuery
@@ -116,6 +134,7 @@ export const getStaticProps: GetStaticProps<
116
134
  operation: query,
117
135
  }),
118
136
  getPLP(slug, previewData, rewrites),
137
+ globalSectionsPromise,
119
138
  ])
120
139
 
121
140
  const notFound = errors.find(isNotFoundError)
@@ -135,7 +154,7 @@ export const getStaticProps: GetStaticProps<
135
154
  props: {
136
155
  data,
137
156
  page: cmsPage,
138
- globalSections: await globalSectionsPromise,
157
+ globalSections,
139
158
  type: 'plp',
140
159
  key: slug,
141
160
  },
@@ -10,6 +10,7 @@ import {
10
10
  type ServerProductQueryQuery,
11
11
  type ServerProductQueryQueryVariables,
12
12
  } from '@generated/graphql'
13
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
13
14
  import RenderSections from 'src/components/cms/RenderSections'
14
15
  import BannerNewsletter from 'src/components/sections/BannerNewsletter/BannerNewsletter'
15
16
  import { OverriddenDefaultBannerText as BannerText } from 'src/components/sections/BannerText/OverriddenDefaultBannerText'
@@ -25,7 +26,7 @@ import { useSession } from 'src/sdk/session'
25
26
  import { execute } from 'src/server'
26
27
 
27
28
  import storeConfig from 'discovery.config'
28
- import GlobalSections, {
29
+ import {
29
30
  GlobalSectionsData,
30
31
  getGlobalSectionsData,
31
32
  } from 'src/components/cms/GlobalSections'
@@ -38,6 +39,7 @@ import { PDPContentType, getPDP } from 'src/server/cms/pdp'
38
39
  * Do not import or render components from any other folder in here.
39
40
  */
40
41
  const COMPONENTS: Record<string, ComponentType<any>> = {
42
+ ...GLOBAL_COMPONENTS,
41
43
  Breadcrumb,
42
44
  BannerNewsletter,
43
45
  Newsletter,
@@ -82,7 +84,7 @@ function Page({ data: server, sections, globalSections, offers, meta }: Props) {
82
84
  } as PDPContext
83
85
 
84
86
  return (
85
- <GlobalSections {...globalSections}>
87
+ <>
86
88
  {/* SEO */}
87
89
  <NextSeo
88
90
  title={meta.title}
@@ -136,9 +138,13 @@ function Page({ data: server, sections, globalSections, offers, meta }: Props) {
136
138
  (not the HTML tag) before rendering it here.
137
139
  */}
138
140
  <PageProvider context={context}>
139
- <RenderSections sections={sections} components={COMPONENTS} />
141
+ <RenderSections
142
+ sections={sections}
143
+ globalSections={globalSections.sections}
144
+ components={COMPONENTS}
145
+ />
140
146
  </PageProvider>
141
- </GlobalSections>
147
+ </>
142
148
  )
143
149
  }
144
150
 
@@ -1,29 +1,41 @@
1
- import { useEffect } from 'react'
1
+ import { Locator } from '@vtex/client-cms'
2
+ import { GetStaticProps } from 'next'
2
3
  import { NextSeo } from 'next-seo'
3
-
4
- import storeConfig from '../../discovery.config'
5
- import GlobalSections, {
4
+ import type { ComponentType } from 'react'
5
+ import { useEffect } from 'react'
6
+ import {
6
7
  GlobalSectionsData,
7
8
  getGlobalSectionsData,
8
9
  } from 'src/components/cms/GlobalSections'
9
- import { GetStaticProps } from 'next'
10
- import { Locator } from '@vtex/client-cms'
10
+ import RenderSections from 'src/components/cms/RenderSections'
11
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
12
+ import CUSTOM_COMPONENTS from 'src/customizations/src/components'
13
+ import storeConfig from '../../discovery.config'
11
14
 
12
15
  type Props = {
13
16
  globalSections: GlobalSectionsData
14
17
  }
15
18
 
19
+ /* A list of components that can be used in the CMS. */
20
+ const COMPONENTS: Record<string, ComponentType<any>> = {
21
+ ...GLOBAL_COMPONENTS,
22
+ ...CUSTOM_COMPONENTS,
23
+ }
24
+
16
25
  function Page({ globalSections }: Props) {
17
26
  useEffect(() => {
18
27
  window.location.href = `${storeConfig.accountUrl}${window.location.search}`
19
28
  }, [])
20
29
 
21
30
  return (
22
- <GlobalSections {...globalSections}>
31
+ <RenderSections
32
+ globalSections={globalSections.sections}
33
+ components={COMPONENTS}
34
+ >
23
35
  <NextSeo noindex nofollow />
24
36
 
25
37
  <div>loading...</div>
26
- </GlobalSections>
38
+ </RenderSections>
27
39
  )
28
40
  }
29
41
 
@@ -1,4 +1,5 @@
1
1
  import type { NextApiHandler, NextApiRequest } from 'next'
2
+ import type { Locator } from '@vtex/client-cms'
2
3
 
3
4
  import { clientCMS } from 'src/server/cms'
4
5
  import { previewRedirects } from '../../../discovery.config'
@@ -20,10 +21,7 @@ const pickParam = (req: NextApiRequest, parameter: string) => {
20
21
  const maybeParam = req.query[parameter]
21
22
 
22
23
  if (typeof maybeParam !== 'string') {
23
- throw new StatusError(
24
- `Parameter ${parameter} missing from querystring`,
25
- 400
26
- )
24
+ return undefined
27
25
  }
28
26
 
29
27
  return maybeParam
@@ -32,14 +30,37 @@ const pickParam = (req: NextApiRequest, parameter: string) => {
32
30
  // TODO: Improve security by disabling CMS preview in production
33
31
  const handler: NextApiHandler = async (req, res) => {
34
32
  try {
35
- const locator = {
36
- contentType: pickParam(req, 'contentType'),
37
- documentId: pickParam(req, 'documentId'),
38
- versionId: pickParam(req, 'versionId'),
33
+ const locator = [
34
+ 'contentType',
35
+ 'documentId',
36
+ 'versionId',
37
+ 'releaseId',
38
+ ].reduce((acc, param) => {
39
+ const value = pickParam(req, param)
40
+
41
+ if (value !== undefined) acc[param] = value
42
+
43
+ return acc
44
+ }, {} as Record<string, string>)
45
+
46
+ // Check if required path params are present
47
+ if (!locator.contentType || !locator.documentId) {
48
+ throw new StatusError(
49
+ `The following path params are required: contentType, documentId`,
50
+ 400
51
+ )
52
+ }
53
+
54
+ // Check if at least one of the querystring params are present
55
+ if (!locator.versionId && !locator.releaseId) {
56
+ throw new StatusError(
57
+ `One of the following querystring params are required: versionId, releaseId`,
58
+ 400
59
+ )
39
60
  }
40
61
 
41
62
  // Fetch CMS to check if the provided `locator` exists
42
- const page = await clientCMS.getCMSPage(locator)
63
+ const page = await clientCMS.getCMSPage(locator as Locator)
43
64
 
44
65
  // If the content doesn't exist prevent preview mode from being enabled
45
66
  if (!page) {
@@ -56,8 +77,9 @@ const handler: NextApiHandler = async (req, res) => {
56
77
  })
57
78
 
58
79
  // Redirect to the path from the fetched locator
59
- if (previewRedirects[locator.contentType]) {
60
- res.redirect(previewRedirects[locator.contentType])
80
+ const redirects = previewRedirects as Record<string, string>
81
+ if (redirects[locator.contentType]) {
82
+ res.redirect(redirects[locator.contentType])
61
83
  return
62
84
  }
63
85
 
@@ -1,29 +1,43 @@
1
- import { useEffect } from 'react'
2
1
  import { NextSeo } from 'next-seo'
2
+ import { useEffect } from 'react'
3
3
 
4
- import storeConfig from '../../discovery.config'
5
- import GlobalSections, {
4
+ import { Locator } from '@vtex/client-cms'
5
+ import { GetStaticProps } from 'next'
6
+ import type { ComponentType } from 'react'
7
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
8
+ import {
6
9
  GlobalSectionsData,
7
10
  getGlobalSectionsData,
8
11
  } from 'src/components/cms/GlobalSections'
9
- import { GetStaticProps } from 'next'
10
- import { Locator } from '@vtex/client-cms'
12
+ import CUSTOM_COMPONENTS from 'src/customizations/src/components'
13
+
14
+ import RenderSections from 'src/components/cms/RenderSections'
15
+ import storeConfig from '../../discovery.config'
11
16
 
12
17
  type Props = {
13
18
  globalSections: GlobalSectionsData
14
19
  }
15
20
 
21
+ /* A list of components that can be used in the CMS. */
22
+ const COMPONENTS: Record<string, ComponentType<any>> = {
23
+ ...GLOBAL_COMPONENTS,
24
+ ...CUSTOM_COMPONENTS,
25
+ }
26
+
16
27
  function Page({ globalSections }: Props) {
17
28
  useEffect(() => {
18
29
  window.location.href = storeConfig.checkoutUrl
19
30
  }, [])
20
31
 
21
32
  return (
22
- <GlobalSections {...globalSections}>
33
+ <RenderSections
34
+ globalSections={globalSections.sections}
35
+ components={COMPONENTS}
36
+ >
23
37
  <NextSeo noindex nofollow />
24
38
 
25
39
  <div>loading...</div>
26
- </GlobalSections>
40
+ </RenderSections>
27
41
  )
28
42
  }
29
43
 
@@ -1,38 +1,20 @@
1
1
  import type { Locator } from '@vtex/client-cms'
2
2
  import type { GetStaticProps } from 'next'
3
3
  import { NextSeo, SiteLinksSearchBoxJsonLd } from 'next-seo'
4
- import type { ComponentType } from 'react'
5
4
 
6
5
  import RenderSections from 'src/components/cms/RenderSections'
7
- import { OverriddenDefaultBannerText as BannerText } from 'src/components/sections/BannerText/OverriddenDefaultBannerText'
8
- import { OverriddenDefaultHero as Hero } from 'src/components/sections/Hero/OverriddenDefaultHero'
9
- import Incentives from 'src/components/sections/Incentives'
10
- import { OverriddenDefaultNewsletter as Newsletter } from 'src/components/sections/Newsletter/OverriddenDefaultNewsletter'
11
- import { OverriddenDefaultProductShelf as ProductShelf } from 'src/components/sections/ProductShelf/OverriddenDefaultProductShelf'
12
- import ProductTiles from 'src/components/sections/ProductTiles'
13
- import CUSTOM_COMPONENTS from 'src/customizations/src/components'
14
6
  import type { PageContentType } from 'src/server/cms'
15
7
  import { getPage } from 'src/server/cms'
16
8
 
17
- import GlobalSections, {
9
+ import {
18
10
  GlobalSectionsData,
19
11
  getGlobalSectionsData,
20
12
  } from 'src/components/cms/GlobalSections'
13
+ import COMPONENTS from 'src/components/cms/home/Components'
21
14
  import PageProvider from 'src/sdk/overrides/PageProvider'
22
15
  import { getDynamicContent } from 'src/utils/dynamicContent'
23
16
  import storeConfig from '../../discovery.config'
24
17
 
25
- /* A list of components that can be used in the CMS. */
26
- const COMPONENTS: Record<string, ComponentType<any>> = {
27
- Hero,
28
- Incentives,
29
- ProductShelf,
30
- ProductTiles,
31
- BannerText,
32
- Newsletter,
33
- ...CUSTOM_COMPONENTS,
34
- }
35
-
36
18
  type Props = {
37
19
  page: PageContentType
38
20
  globalSections: GlobalSectionsData
@@ -49,7 +31,7 @@ function Page({
49
31
  }
50
32
 
51
33
  return (
52
- <GlobalSections {...globalSections}>
34
+ <>
53
35
  {/* SEO */}
54
36
  <NextSeo
55
37
  title={settings?.seo?.title ?? storeConfig.seo.title}
@@ -86,9 +68,13 @@ function Page({
86
68
  (not the HTML tag) before rendering it here.
87
69
  */}
88
70
  <PageProvider context={context}>
89
- <RenderSections sections={sections} components={COMPONENTS} />
71
+ <RenderSections
72
+ globalSections={globalSections.sections}
73
+ sections={sections}
74
+ components={COMPONENTS}
75
+ />
90
76
  </PageProvider>
91
- </GlobalSections>
77
+ </>
92
78
  )
93
79
  }
94
80
 
@@ -1,21 +1,23 @@
1
- import { useEffect } from 'react'
2
1
  import { NextSeo } from 'next-seo'
3
2
  import type { ComponentType } from 'react'
3
+ import { useEffect } from 'react'
4
4
 
5
- import storeConfig from '../../discovery.config'
6
- import GlobalSections, {
5
+ import { Locator } from '@vtex/client-cms'
6
+ import { GetStaticProps } from 'next'
7
+ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Components'
8
+ import {
7
9
  GlobalSectionsData,
8
10
  getGlobalSectionsData,
9
11
  } from 'src/components/cms/GlobalSections'
10
- import { GetStaticProps } from 'next'
11
- import { Locator } from '@vtex/client-cms'
12
12
  import RenderSections from 'src/components/cms/RenderSections'
13
13
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
14
14
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
15
15
  import { PageContentType, getPage } from 'src/server/cms'
16
+ import storeConfig from '../../discovery.config'
16
17
 
17
18
  /* A list of components that can be used in the CMS. */
18
19
  const COMPONENTS: Record<string, ComponentType<any>> = {
20
+ ...GLOBAL_COMPONENTS,
19
21
  EmptyState,
20
22
  ...CUSTOM_COMPONENTS,
21
23
  }
@@ -38,7 +40,7 @@ function Page({ page: { sections }, globalSections }: Props) {
38
40
  }, [])
39
41
 
40
42
  return (
41
- <GlobalSections {...globalSections}>
43
+ <>
42
44
  <NextSeo noindex nofollow />
43
45
  {/*
44
46
  WARNING: Do not import or render components from any
@@ -51,8 +53,12 @@ function Page({ page: { sections }, globalSections }: Props) {
51
53
  If needed, wrap your component in a <Section /> component
52
54
  (not the HTML tag) before rendering it here.
53
55
  */}
54
- <RenderSections sections={sections} components={COMPONENTS} />
55
- </GlobalSections>
56
+ <RenderSections
57
+ sections={sections}
58
+ globalSections={globalSections.sections}
59
+ components={COMPONENTS}
60
+ />
61
+ </>
56
62
  )
57
63
  }
58
64
 
package/src/pages/s.tsx CHANGED
@@ -1,7 +1,7 @@
1
- import { useMemo } from 'react'
1
+ import type { GetStaticProps } from 'next'
2
2
  import { NextSeo } from 'next-seo'
3
3
  import { useRouter } from 'next/router'
4
- import type { GetStaticProps } from 'next'
4
+ import { useMemo } from 'react'
5
5
 
6
6
  import type { SearchState } from '@faststore/sdk'
7
7
  import {
@@ -16,7 +16,7 @@ import { useApplySearchState } from 'src/sdk/search/state'
16
16
 
17
17
  import { Locator } from '@vtex/client-cms'
18
18
  import storeConfig from 'discovery.config'
19
- import GlobalSections, {
19
+ import {
20
20
  getGlobalSectionsData,
21
21
  GlobalSectionsData,
22
22
  } from 'src/components/cms/GlobalSections'
@@ -70,28 +70,27 @@ function Page({ page: searchContentType, globalSections }: Props) {
70
70
  }
71
71
 
72
72
  return (
73
- <GlobalSections {...globalSections}>
74
- <SearchProvider
75
- onChange={applySearchState}
76
- itemsPerPage={itemsPerPage}
77
- {...searchParams}
78
- >
79
- {/* SEO */}
80
- <NextSeo
81
- noindex
82
- title={title}
83
- description={description}
84
- titleTemplate={titleTemplate}
85
- openGraph={{
86
- type: 'website',
87
- title,
88
- description,
89
- }}
90
- />
91
-
92
- <UISROnly text={title} />
93
-
94
- {/*
73
+ <SearchProvider
74
+ onChange={applySearchState}
75
+ itemsPerPage={itemsPerPage}
76
+ {...searchParams}
77
+ >
78
+ {/* SEO */}
79
+ <NextSeo
80
+ noindex
81
+ title={title}
82
+ description={description}
83
+ titleTemplate={titleTemplate}
84
+ openGraph={{
85
+ type: 'website',
86
+ title,
87
+ description,
88
+ }}
89
+ />
90
+
91
+ <UISROnly text={title} />
92
+
93
+ {/*
95
94
  WARNING: Do not import or render components from any
96
95
  other folder than '../components/sections' in here.
97
96
 
@@ -102,16 +101,16 @@ function Page({ page: searchContentType, globalSections }: Props) {
102
101
  If needed, wrap your component in a <Section /> component
103
102
  (not the HTML tag) before rendering it here.
104
103
  */}
105
- <SearchWrapper
106
- itemsPerPage={itemsPerPage}
107
- searchContentType={searchContentType}
108
- serverData={{
109
- title,
110
- searchTerm: searchParams.term ?? undefined,
111
- }}
112
- />
113
- </SearchProvider>
114
- </GlobalSections>
104
+ <SearchWrapper
105
+ itemsPerPage={itemsPerPage}
106
+ searchContentType={searchContentType}
107
+ serverData={{
108
+ title,
109
+ searchTerm: searchParams.term ?? undefined,
110
+ }}
111
+ globalSections={globalSections.sections}
112
+ />
113
+ </SearchProvider>
115
114
  )
116
115
  }
117
116