create-brainerce-store 1.28.9 → 1.28.11
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/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var require_package = __commonJS({
|
|
|
31
31
|
"package.json"(exports2, module2) {
|
|
32
32
|
module2.exports = {
|
|
33
33
|
name: "create-brainerce-store",
|
|
34
|
-
version: "1.28.
|
|
34
|
+
version: "1.28.11",
|
|
35
35
|
description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
|
|
36
36
|
bin: {
|
|
37
37
|
"create-brainerce-store": "dist/index.js"
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
|
+
import { headers } from 'next/headers';
|
|
2
3
|
import { notFound } from 'next/navigation';
|
|
3
4
|
import { getServerClient } from '@/lib/brainerce';
|
|
4
5
|
import { ProductJsonLd } from '@/components/seo/product-json-ld';
|
|
@@ -8,12 +9,19 @@ type Props = {
|
|
|
8
9
|
params: Promise<{ slug: string }>;
|
|
9
10
|
};
|
|
10
11
|
|
|
12
|
+
// Read the locale the middleware set on this request so the SDK can resolve
|
|
13
|
+
// translated slugs (translations[locale].slug) in addition to the base slug.
|
|
14
|
+
async function getRequestLocale(): Promise<string | undefined> {
|
|
15
|
+
return (await headers()).get('x-locale') ?? undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
12
19
|
const { slug } = await params;
|
|
20
|
+
const locale = await getRequestLocale();
|
|
13
21
|
|
|
14
22
|
try {
|
|
15
23
|
const client = getServerClient();
|
|
16
|
-
const product = await client.getProductBySlug(slug);
|
|
24
|
+
const product = await client.getProductBySlug(slug, { locale });
|
|
17
25
|
const imageUrl = product.images?.[0]?.url;
|
|
18
26
|
const description = product.description?.substring(0, 160) || product.name;
|
|
19
27
|
|
|
@@ -45,11 +53,12 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
|
45
53
|
|
|
46
54
|
export default async function ProductDetailPage({ params }: Props) {
|
|
47
55
|
const { slug } = await params;
|
|
56
|
+
const locale = await getRequestLocale();
|
|
48
57
|
|
|
49
58
|
let product;
|
|
50
59
|
try {
|
|
51
60
|
const client = getServerClient();
|
|
52
|
-
product = await client.getProductBySlug(slug);
|
|
61
|
+
product = await client.getProductBySlug(slug, { locale });
|
|
53
62
|
} catch {
|
|
54
63
|
notFound();
|
|
55
64
|
}
|