create-brainerce-store 1.28.13 → 1.28.17
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 +1 -1
- package/messages/en.json +390 -389
- package/messages/he.json +390 -389
- package/package.json +46 -46
- package/templates/nextjs/base/next.config.ts +47 -47
- package/templates/nextjs/base/src/app/api/auth/logout/route.ts +15 -15
- package/templates/nextjs/base/src/app/api/auth/oauth-callback/route.ts +66 -66
- package/templates/nextjs/base/src/app/api/auth/reset-password/route.ts +76 -76
- package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +235 -229
- package/templates/nextjs/base/src/app/checkout/page.tsx +975 -975
- package/templates/nextjs/base/src/app/products/[slug]/page.tsx +73 -76
- package/templates/nextjs/base/src/app/products/[slug]/product-client-section.tsx +529 -501
- package/templates/nextjs/base/src/app/products/page.tsx +475 -482
- package/templates/nextjs/base/src/app/reset-password/page.tsx +138 -138
- package/templates/nextjs/base/src/components/auth/register-form.tsx +245 -245
- package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +416 -416
- package/templates/nextjs/base/src/components/checkout/payment-step.tsx +656 -656
- package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +88 -88
- package/templates/nextjs/base/src/lib/brainerce.ts.ejs +6 -2
- package/templates/nextjs/base/src/lib/csrf.ts +11 -11
- package/templates/nextjs/base/src/lib/nonce.ts +10 -10
- package/templates/nextjs/base/src/lib/safe-redirect.ts +45 -45
- package/templates/nextjs/base/src/lib/sanitize-html.ts +93 -93
- package/templates/nextjs/base/src/lib/validation.ts +37 -37
|
@@ -1,76 +1,73 @@
|
|
|
1
|
-
import type { Metadata } from 'next';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
1
|
+
import type { Metadata } from 'next';
|
|
2
|
+
import { notFound } from 'next/navigation';
|
|
3
|
+
import { getServerClient } from '@/lib/brainerce';
|
|
4
|
+
import { ProductJsonLd } from '@/components/seo/product-json-ld';
|
|
5
|
+
import { ProductClientSection } from './product-client-section';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
params: Promise<{ slug: string; locale?: string }>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
12
|
+
const { slug, locale } = await params;
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const client = getServerClient(locale);
|
|
16
|
+
const product = await client.getProductBySlug(slug);
|
|
17
|
+
const imageUrl = product.images?.[0]?.url;
|
|
18
|
+
// Prefer merchant-authored SEO copy; fall back to the visible name/description.
|
|
19
|
+
// Both are served already locale-resolved by the backend.
|
|
20
|
+
const seoTitle = (product as { seoTitle?: string | null }).seoTitle || product.name;
|
|
21
|
+
const seoDescription =
|
|
22
|
+
(product as { seoDescription?: string | null }).seoDescription ||
|
|
23
|
+
product.description?.substring(0, 160) ||
|
|
24
|
+
product.name;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
title: seoTitle,
|
|
28
|
+
description: seoDescription,
|
|
29
|
+
alternates: {
|
|
30
|
+
canonical: `/products/${slug}`,
|
|
31
|
+
},
|
|
32
|
+
openGraph: {
|
|
33
|
+
title: seoTitle,
|
|
34
|
+
description: seoDescription,
|
|
35
|
+
images: imageUrl ? [{ url: imageUrl, alt: product.name }] : [],
|
|
36
|
+
type: 'website',
|
|
37
|
+
},
|
|
38
|
+
twitter: {
|
|
39
|
+
card: 'summary_large_image',
|
|
40
|
+
title: seoTitle,
|
|
41
|
+
description: seoDescription,
|
|
42
|
+
images: imageUrl ? [imageUrl] : [],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
} catch {
|
|
46
|
+
return {
|
|
47
|
+
title: 'Product not found',
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default async function ProductDetailPage({ params }: Props) {
|
|
53
|
+
const { slug, locale } = await params;
|
|
54
|
+
|
|
55
|
+
let product;
|
|
56
|
+
try {
|
|
57
|
+
const client = getServerClient(locale);
|
|
58
|
+
product = await client.getProductBySlug(slug);
|
|
59
|
+
} catch {
|
|
60
|
+
notFound();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || '';
|
|
64
|
+
const productUrl = `${baseUrl}/products/${slug}`;
|
|
65
|
+
const currency = process.env.NEXT_PUBLIC_STORE_CURRENCY || 'USD';
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<ProductJsonLd product={product} url={productUrl} currency={currency} />
|
|
70
|
+
<ProductClientSection product={product} />
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
}
|