create-cartbase 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/app/docs/collections.md +167 -167
- package/template/app/docs/components.md +1294 -1246
- package/template/app/docs/customers.md +3 -4
- package/template/app/docs/products.md +316 -307
- package/template/app/next.config.ts +6 -4
- package/template/app/package.json +1 -1
- package/template/app/src/app/products/[handle]/page.tsx +9 -1
|
@@ -5,10 +5,12 @@ const nextConfig: NextConfig = {
|
|
|
5
5
|
// build transpiles it.
|
|
6
6
|
transpilePackages: ["@cartbase/storefront"],
|
|
7
7
|
images: {
|
|
8
|
-
// Product
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
8
|
+
// Product pictures live on the Cartbase media CDN and Next resizes them
|
|
9
|
+
// on this project, per device, in the modern formats. A picture from
|
|
10
|
+
// any other host renders as it is: the package's image components
|
|
11
|
+
// switch resizing off for hosts not listed here. Add your own hosts to
|
|
12
|
+
// resize them too.
|
|
13
|
+
remotePatterns: [{ protocol: "https", hostname: "cartbase.cloud" }],
|
|
12
14
|
},
|
|
13
15
|
// The Cartbase store API ships NO CORS headers — browser-side SDK calls
|
|
14
16
|
// must be same-origin. Proxy them through the app origin (the browser
|
|
@@ -13,10 +13,12 @@ import { getServerClient } from "@/lib/server-client"
|
|
|
13
13
|
*/
|
|
14
14
|
export default async function ProductPage({
|
|
15
15
|
params,
|
|
16
|
+
searchParams,
|
|
16
17
|
}: {
|
|
17
18
|
params: Promise<{ handle: string }>
|
|
19
|
+
searchParams: Promise<{ variant?: string }>
|
|
18
20
|
}) {
|
|
19
|
-
const { handle } = await params
|
|
21
|
+
const [{ handle }, { variant }] = await Promise.all([params, searchParams])
|
|
20
22
|
const client = await getServerClient()
|
|
21
23
|
|
|
22
24
|
let product
|
|
@@ -34,6 +36,12 @@ export default async function ProductPage({
|
|
|
34
36
|
product={product}
|
|
35
37
|
pricingContext={PRICING_CONTEXT}
|
|
36
38
|
addToCart={addToCartAction}
|
|
39
|
+
// The product page contract: the address names the variant
|
|
40
|
+
// (`?variant=<digits>`, Shopify's parameter), and the page hands it to
|
|
41
|
+
// the template so the FIRST paint is that variant's price, code and
|
|
42
|
+
// stock. Switching a variant rewrites the address in the browser
|
|
43
|
+
// without asking the server.
|
|
44
|
+
initialVariantId={variant}
|
|
37
45
|
// NO `promises` here, deliberately. Until 0.13.0 the library carried
|
|
38
46
|
// delivery, exchange and return promises as label DEFAULTS, so every
|
|
39
47
|
// store scaffolded from this file told shoppers "your package will
|