create-brainerce-store 1.54.0 → 1.57.0
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 +9 -2
- package/package.json +1 -1
- package/templates/nextjs/base/src/app/category/[slug]/page.tsx +16 -2
- package/templates/nextjs/base/src/app/products/[slug]/page.tsx +175 -157
- package/templates/nextjs/base/src/components/seo/breadcrumbs.tsx +37 -0
- package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +49 -2
- package/templates/nextjs/base/src/core/lib/store-info.ts +3 -0
- package/templates/nextjs/designs/atelier/globals.css +26 -20
- package/templates/nextjs/designs/atelier/messages-patch/en.json +13 -13
- package/templates/nextjs/designs/atelier/messages-patch/he.json +15 -15
- package/templates/nextjs/designs/atelier/ui/cart/cart-drawer.tsx +14 -14
- package/templates/nextjs/designs/atelier/ui/home/benefits-band.tsx +5 -5
- package/templates/nextjs/designs/atelier/ui/home/category-tiles.tsx +16 -13
- package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +23 -17
- package/templates/nextjs/designs/atelier/ui/product/product-grid.tsx +6 -11
- package/templates/nextjs/designs/atelier/ui/shared/icons.tsx +276 -269
- package/templates/nextjs/designs/atelier/ui/shared/loading-spinner.tsx +9 -10
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.
|
|
34
|
+
version: "1.57.0",
|
|
35
35
|
description: "Scaffold a production-ready e-commerce storefront connected to Brainerce",
|
|
36
36
|
bin: {
|
|
37
37
|
"create-brainerce-store": "dist/index.js"
|
|
@@ -399,6 +399,9 @@ async function scaffold(options) {
|
|
|
399
399
|
* must keep using the escaped storeNameJs / storeNameEnv variants. */
|
|
400
400
|
storeName: cleanStoreName,
|
|
401
401
|
storeNameJs: toJsStringLiteral(cleanStoreName),
|
|
402
|
+
/** Pre-escaped for splicing into a JSON string value (no wrapping
|
|
403
|
+
* quotes) — used by the `{{storeName}}` token in messages-patch files. */
|
|
404
|
+
storeNameJsonEscaped: JSON.stringify(cleanStoreName).slice(1, -1),
|
|
402
405
|
titleTemplateJs: toJsStringLiteral(`%s | ${cleanStoreName}`),
|
|
403
406
|
storeNameEnv: toEnvLiteral(cleanStoreName),
|
|
404
407
|
currencyEnv: toEnvLiteral(cleanCurrency),
|
|
@@ -479,7 +482,11 @@ async function scaffold(options) {
|
|
|
479
482
|
if (!await import_fs_extra.default.pathExists(patchFile)) continue;
|
|
480
483
|
const targetFile = import_path.default.join(targetMessages, file);
|
|
481
484
|
const base = await import_fs_extra.default.readJson(targetFile);
|
|
482
|
-
const
|
|
485
|
+
const patchText = (await import_fs_extra.default.readFile(patchFile, "utf-8")).replace(
|
|
486
|
+
/\{\{storeName\}\}/g,
|
|
487
|
+
templateVars.storeNameJsonEscaped
|
|
488
|
+
);
|
|
489
|
+
const patch = JSON.parse(patchText);
|
|
483
490
|
await import_fs_extra.default.writeJson(targetFile, deepMerge(base, patch), { spaces: 2 });
|
|
484
491
|
}
|
|
485
492
|
}
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import { buildMetaDescription } from '@/core/lib/seo';
|
|
|
6
6
|
import { sanitizeHtml } from '@/core/lib/sanitize';
|
|
7
7
|
import { decodeSlug } from '@/core/lib/utils';
|
|
8
8
|
import { CategoryJsonLd } from '@/components/seo/category-json-ld';
|
|
9
|
+
import { Breadcrumbs } from '@/components/seo/breadcrumbs';
|
|
9
10
|
import { ProductGrid } from '@/ui/product/product-grid';
|
|
10
11
|
|
|
11
12
|
type Props = {
|
|
@@ -29,8 +30,9 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
|
29
30
|
const description =
|
|
30
31
|
category.metaDescription || buildMetaDescription(category.description) || category.name;
|
|
31
32
|
const canonicalSlug = category.slug || slug;
|
|
32
|
-
const canonicalPath =
|
|
33
|
-
|
|
33
|
+
const canonicalPath = locale
|
|
34
|
+
? `/${locale}/category/${canonicalSlug}`
|
|
35
|
+
: `/category/${canonicalSlug}`;
|
|
34
36
|
return {
|
|
35
37
|
title: category.name,
|
|
36
38
|
description,
|
|
@@ -69,11 +71,23 @@ export default async function CategoryPage({ params }: Props) {
|
|
|
69
71
|
|
|
70
72
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || '';
|
|
71
73
|
const url = `${baseUrl}/category/${category.slug || slug}`;
|
|
74
|
+
const localePrefix = locale ? `/${locale}` : '';
|
|
75
|
+
const breadcrumbItems = [
|
|
76
|
+
{ name: 'Home', href: `${localePrefix}/` },
|
|
77
|
+
...category.breadcrumb
|
|
78
|
+
.filter((ancestor) => ancestor.slug)
|
|
79
|
+
.map((ancestor) => ({
|
|
80
|
+
name: ancestor.name,
|
|
81
|
+
href: `${localePrefix}/category/${ancestor.slug}`,
|
|
82
|
+
})),
|
|
83
|
+
{ name: category.name },
|
|
84
|
+
];
|
|
72
85
|
|
|
73
86
|
return (
|
|
74
87
|
<>
|
|
75
88
|
<CategoryJsonLd category={category} url={url} />
|
|
76
89
|
<div className="container mx-auto px-4 py-8">
|
|
90
|
+
<Breadcrumbs items={breadcrumbItems} />
|
|
77
91
|
<header className="mb-6">
|
|
78
92
|
<h1 className="text-3xl font-bold tracking-tight">{category.name}</h1>
|
|
79
93
|
</header>
|
|
@@ -1,157 +1,175 @@
|
|
|
1
|
-
import type { Metadata } from 'next';
|
|
2
|
-
import { notFound } from 'next/navigation';
|
|
3
|
-
import { getProductPriceInfo } from 'brainerce';
|
|
4
|
-
import { getServerClient, fetchStoreInfo } from '@/core/lib/brainerce';
|
|
5
|
-
import { resolveCurrency } from '@/core/lib/resolve-currency';
|
|
6
|
-
import { buildMetaDescription } from '@/core/lib/seo';
|
|
7
|
-
import { decodeSlug } from '@/core/lib/utils';
|
|
8
|
-
import { ProductJsonLd } from '@/components/seo/product-json-ld';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const slug =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
product.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
'og:price:
|
|
114
|
-
'
|
|
115
|
-
'product:price:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
'product:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const slug =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
1
|
+
import type { Metadata } from 'next';
|
|
2
|
+
import { notFound } from 'next/navigation';
|
|
3
|
+
import { getProductPriceInfo } from 'brainerce';
|
|
4
|
+
import { getServerClient, fetchStoreInfo } from '@/core/lib/brainerce';
|
|
5
|
+
import { resolveCurrency } from '@/core/lib/resolve-currency';
|
|
6
|
+
import { buildMetaDescription } from '@/core/lib/seo';
|
|
7
|
+
import { decodeSlug } from '@/core/lib/utils';
|
|
8
|
+
import { ProductJsonLd } from '@/components/seo/product-json-ld';
|
|
9
|
+
import { Breadcrumbs } from '@/components/seo/breadcrumbs';
|
|
10
|
+
import { ReviewsSection } from '@/ui/product/reviews-section';
|
|
11
|
+
import { ProductClientSection } from '@/ui/product/product-client-section';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
params: Promise<{ slug: string; locale?: string }>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function buildHreflang(
|
|
18
|
+
baseUrl: string,
|
|
19
|
+
baseSlug: string,
|
|
20
|
+
localeSlugs: Record<string, string>,
|
|
21
|
+
locales: string[],
|
|
22
|
+
defaultLoc: string
|
|
23
|
+
): Record<string, string> {
|
|
24
|
+
const langs: Record<string, string> = {};
|
|
25
|
+
for (const loc of locales) {
|
|
26
|
+
const locSlug = localeSlugs[loc] || baseSlug;
|
|
27
|
+
const path = loc === defaultLoc ? `/products/${locSlug}` : `/${loc}/products/${locSlug}`;
|
|
28
|
+
langs[loc] = `${baseUrl}${path}`;
|
|
29
|
+
}
|
|
30
|
+
// x-default points to the default-locale canonical (no prefix)
|
|
31
|
+
langs['x-default'] = `${baseUrl}/products/${localeSlugs[defaultLoc] || baseSlug}`;
|
|
32
|
+
return langs;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
36
|
+
const { slug: rawSlug, locale } = await params;
|
|
37
|
+
const slug = decodeSlug(rawSlug);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const client = getServerClient(locale);
|
|
41
|
+
// Fetch product + store info in parallel; storeInfo gives us the live
|
|
42
|
+
// currency for OG price tags (with env-var + USD fallbacks so we never
|
|
43
|
+
// silently emit a wrong currency when the API is briefly unreachable).
|
|
44
|
+
const [product, storeInfo] = await Promise.all([
|
|
45
|
+
client.getProductBySlug(slug),
|
|
46
|
+
fetchStoreInfo(locale),
|
|
47
|
+
]);
|
|
48
|
+
const imageUrl = product.images?.[0]?.url;
|
|
49
|
+
// Prefer merchant-authored SEO copy; fall back to a stripped+truncated
|
|
50
|
+
// version of the visible description, then product name. We must NEVER
|
|
51
|
+
// emit raw HTML or a mid-word cut into <meta name="description">.
|
|
52
|
+
const seoTitle = (product as { seoTitle?: string | null }).seoTitle || product.name;
|
|
53
|
+
const seoDescription =
|
|
54
|
+
(product as { seoDescription?: string | null }).seoDescription ||
|
|
55
|
+
buildMetaDescription(product.description) ||
|
|
56
|
+
product.name;
|
|
57
|
+
|
|
58
|
+
// OG product meta tags drive WhatsApp / Facebook / X link previews and
|
|
59
|
+
// Google Merchant Center product enrichment. Emitting the literal "0"
|
|
60
|
+
// here (the previous bug) causes price-zero link cards. Use the real
|
|
61
|
+
// effective price from the SDK helper.
|
|
62
|
+
const priceInfo = getProductPriceInfo(product);
|
|
63
|
+
const currency = resolveCurrency(storeInfo);
|
|
64
|
+
const priceAmount = priceInfo.price > 0 ? priceInfo.price.toFixed(2) : null;
|
|
65
|
+
const inStock = product.inventory?.canPurchase !== false;
|
|
66
|
+
const brandName = (product as { brand?: { name?: string } | null }).brand?.name;
|
|
67
|
+
|
|
68
|
+
// Multilingual SEO: hreflang tags + correct canonical per locale.
|
|
69
|
+
// Locales come from storeInfo.i18n — already fetched above, zero extra cost.
|
|
70
|
+
const supportedLocales = storeInfo?.i18n?.supportedLocales ?? [];
|
|
71
|
+
const defaultLoc = storeInfo?.i18n?.defaultLocale ?? storeInfo?.language ?? '';
|
|
72
|
+
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || '';
|
|
73
|
+
const baseSlug = product.slug || slug;
|
|
74
|
+
const localeSlugs = product.localeSlugs ?? {};
|
|
75
|
+
|
|
76
|
+
// Canonical: use the locale-specific slug for this locale when available.
|
|
77
|
+
const canonicalSlug = (locale && localeSlugs[locale]) || baseSlug;
|
|
78
|
+
const canonicalPath =
|
|
79
|
+
locale && locale !== defaultLoc
|
|
80
|
+
? `/${locale}/products/${canonicalSlug}`
|
|
81
|
+
: `/products/${canonicalSlug}`;
|
|
82
|
+
|
|
83
|
+
const hreflangLanguages =
|
|
84
|
+
supportedLocales.length > 1
|
|
85
|
+
? buildHreflang(baseUrl, baseSlug, localeSlugs, supportedLocales, defaultLoc)
|
|
86
|
+
: undefined;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
title: seoTitle,
|
|
90
|
+
description: seoDescription,
|
|
91
|
+
alternates: {
|
|
92
|
+
canonical: canonicalPath,
|
|
93
|
+
...(hreflangLanguages ? { languages: hreflangLanguages } : {}),
|
|
94
|
+
},
|
|
95
|
+
openGraph: {
|
|
96
|
+
title: seoTitle,
|
|
97
|
+
description: seoDescription,
|
|
98
|
+
images: imageUrl ? [{ url: imageUrl, alt: product.name }] : [],
|
|
99
|
+
type: 'website',
|
|
100
|
+
},
|
|
101
|
+
twitter: {
|
|
102
|
+
card: 'summary_large_image',
|
|
103
|
+
title: seoTitle,
|
|
104
|
+
description: seoDescription,
|
|
105
|
+
images: imageUrl ? [imageUrl] : [],
|
|
106
|
+
},
|
|
107
|
+
// Emit the OG product extension (Facebook / WhatsApp / X link previews,
|
|
108
|
+
// Google Merchant Center). Skips the price pair entirely when the SDK
|
|
109
|
+
// can't determine a positive amount, rather than shipping "0".
|
|
110
|
+
other: {
|
|
111
|
+
...(priceAmount
|
|
112
|
+
? {
|
|
113
|
+
'og:price:amount': priceAmount,
|
|
114
|
+
'og:price:currency': currency,
|
|
115
|
+
'product:price:amount': priceAmount,
|
|
116
|
+
'product:price:currency': currency,
|
|
117
|
+
}
|
|
118
|
+
: {}),
|
|
119
|
+
'product:availability': inStock ? 'in stock' : 'out of stock',
|
|
120
|
+
'product:condition': 'new',
|
|
121
|
+
...(brandName ? { 'product:brand': brandName } : {}),
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
} catch {
|
|
125
|
+
return {
|
|
126
|
+
title: 'Product not found',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default async function ProductDetailPage({ params }: Props) {
|
|
132
|
+
const { slug: rawSlug, locale } = await params;
|
|
133
|
+
const slug = decodeSlug(rawSlug);
|
|
134
|
+
|
|
135
|
+
let product;
|
|
136
|
+
try {
|
|
137
|
+
const client = getServerClient(locale);
|
|
138
|
+
product = await client.getProductBySlug(slug);
|
|
139
|
+
} catch {
|
|
140
|
+
notFound();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || '';
|
|
144
|
+
const productUrl = `${baseUrl}/products/${slug}`;
|
|
145
|
+
// Reuse the cached storeInfo from generateMetadata's call — React cache()
|
|
146
|
+
// collapses both into one backend request per render. resolveCurrency owns
|
|
147
|
+
// the env-var + USD fallback chain so this stays a single source of truth.
|
|
148
|
+
const storeInfo = await fetchStoreInfo(locale);
|
|
149
|
+
const currency = resolveCurrency(storeInfo);
|
|
150
|
+
const localePrefix = locale ? `/${locale}` : '';
|
|
151
|
+
const primaryCategory = product.categories?.find((c) => c.slug);
|
|
152
|
+
const breadcrumbItems = [
|
|
153
|
+
{ name: 'Home', href: `${localePrefix}/` },
|
|
154
|
+
...(primaryCategory
|
|
155
|
+
? [{ name: primaryCategory.name, href: `${localePrefix}/category/${primaryCategory.slug}` }]
|
|
156
|
+
: []),
|
|
157
|
+
{ name: product.name },
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
<ProductJsonLd
|
|
163
|
+
product={product}
|
|
164
|
+
url={productUrl}
|
|
165
|
+
currency={currency}
|
|
166
|
+
shipping={storeInfo?.shipping}
|
|
167
|
+
/>
|
|
168
|
+
<div className="mx-auto max-w-7xl px-4 pt-6 sm:px-6 lg:px-8">
|
|
169
|
+
<Breadcrumbs items={breadcrumbItems} />
|
|
170
|
+
</div>
|
|
171
|
+
<ProductClientSection product={product} />
|
|
172
|
+
<ReviewsSection productId={product.id} />
|
|
173
|
+
</>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Link from 'next/link';
|
|
2
|
+
|
|
3
|
+
interface Crumb {
|
|
4
|
+
name: string;
|
|
5
|
+
/** Site-relative path, e.g. "/category/shoes". Omit on the current (last) crumb. */
|
|
6
|
+
href?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Visible breadcrumb trail. Renders the exact same path structured data
|
|
11
|
+
* already declares (see category-json-ld.tsx / product-json-ld.tsx) as real
|
|
12
|
+
* `<Link>`s — search engines weight on-page navigation links much more than
|
|
13
|
+
* sitemap-only or script-only (JSON-LD) mentions of a URL.
|
|
14
|
+
*/
|
|
15
|
+
export function Breadcrumbs({ items }: { items: Crumb[] }) {
|
|
16
|
+
if (items.length < 2) return null;
|
|
17
|
+
return (
|
|
18
|
+
<nav aria-label="Breadcrumb" className="text-muted-foreground mb-4 text-sm">
|
|
19
|
+
<ol className="flex flex-wrap items-center gap-1.5">
|
|
20
|
+
{items.map((item, idx) => (
|
|
21
|
+
<li key={`${item.name}-${idx}`} className="flex items-center gap-1.5">
|
|
22
|
+
{idx > 0 && <span aria-hidden="true">/</span>}
|
|
23
|
+
{item.href ? (
|
|
24
|
+
<Link href={item.href} className="hover:text-foreground transition-colors">
|
|
25
|
+
{item.name}
|
|
26
|
+
</Link>
|
|
27
|
+
) : (
|
|
28
|
+
<span aria-current="page" className="text-foreground">
|
|
29
|
+
{item.name}
|
|
30
|
+
</span>
|
|
31
|
+
)}
|
|
32
|
+
</li>
|
|
33
|
+
))}
|
|
34
|
+
</ol>
|
|
35
|
+
</nav>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Product } from 'brainerce';
|
|
1
|
+
import type { Product, ShippingSummaryEntry } from 'brainerce';
|
|
2
2
|
import { getProductPriceInfo } from 'brainerce';
|
|
3
3
|
import { getNonce } from '@/core/lib/nonce';
|
|
4
4
|
import { resolveCurrency } from '@/core/lib/resolve-currency';
|
|
@@ -8,9 +8,11 @@ interface ProductJsonLdProps {
|
|
|
8
8
|
product: Product;
|
|
9
9
|
url: string;
|
|
10
10
|
currency?: string;
|
|
11
|
+
/** From `storeInfo.shipping` — real flat-rate/free zones only. Omitted entirely when unset, never fabricated. */
|
|
12
|
+
shipping?: ShippingSummaryEntry[];
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
export async function ProductJsonLd({ product, url, currency }: ProductJsonLdProps) {
|
|
15
|
+
export async function ProductJsonLd({ product, url, currency, shipping }: ProductJsonLdProps) {
|
|
14
16
|
// Defer to the shared server helper so the env-var + USD fallback chain
|
|
15
17
|
// lives in exactly one place across all server-side currency reads.
|
|
16
18
|
const resolvedCurrency = resolveCurrency(null, currency);
|
|
@@ -24,6 +26,44 @@ export async function ProductJsonLd({ product, url, currency }: ProductJsonLdPro
|
|
|
24
26
|
? 'https://schema.org/InStock'
|
|
25
27
|
: 'https://schema.org/OutOfStock';
|
|
26
28
|
|
|
29
|
+
// All Brainerce catalog listings are first-party new-goods sales — no
|
|
30
|
+
// used/refurbished condition data exists anywhere in the product model, so
|
|
31
|
+
// this is a deliberate always-true assumption, not a per-product field.
|
|
32
|
+
const itemCondition = 'https://schema.org/NewCondition';
|
|
33
|
+
|
|
34
|
+
const shippingDetails = (shipping ?? [])
|
|
35
|
+
.filter((z) => z.amount !== null)
|
|
36
|
+
.map((z) => ({
|
|
37
|
+
'@type': 'OfferShippingDetails',
|
|
38
|
+
shippingRate: { '@type': 'MonetaryAmount', value: z.amount, currency: resolvedCurrency },
|
|
39
|
+
shippingDestination: { '@type': 'DefinedRegion', addressCountry: z.countries },
|
|
40
|
+
...(z.handlingTime != null || z.minDeliveryDays != null || z.maxDeliveryDays != null
|
|
41
|
+
? {
|
|
42
|
+
deliveryTime: {
|
|
43
|
+
'@type': 'ShippingDeliveryTime',
|
|
44
|
+
...(z.handlingTime != null
|
|
45
|
+
? {
|
|
46
|
+
handlingTime: {
|
|
47
|
+
'@type': 'QuantitativeValue',
|
|
48
|
+
minValue: 0,
|
|
49
|
+
maxValue: z.handlingTime,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: {}),
|
|
53
|
+
...(z.minDeliveryDays != null || z.maxDeliveryDays != null
|
|
54
|
+
? {
|
|
55
|
+
transitTime: {
|
|
56
|
+
'@type': 'QuantitativeValue',
|
|
57
|
+
minValue: z.minDeliveryDays ?? z.maxDeliveryDays,
|
|
58
|
+
maxValue: z.maxDeliveryDays ?? z.minDeliveryDays,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
: {}),
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
: {}),
|
|
65
|
+
}));
|
|
66
|
+
|
|
27
67
|
const isVariable = product.type === 'VARIABLE';
|
|
28
68
|
const offers =
|
|
29
69
|
isVariable && product.priceMin
|
|
@@ -34,6 +74,8 @@ export async function ProductJsonLd({ product, url, currency }: ProductJsonLdPro
|
|
|
34
74
|
offerCount: product.variants?.length ?? 1,
|
|
35
75
|
priceCurrency: resolvedCurrency,
|
|
36
76
|
availability,
|
|
77
|
+
itemCondition,
|
|
78
|
+
...(shippingDetails.length > 0 ? { shippingDetails } : {}),
|
|
37
79
|
url,
|
|
38
80
|
}
|
|
39
81
|
: {
|
|
@@ -41,6 +83,11 @@ export async function ProductJsonLd({ product, url, currency }: ProductJsonLdPro
|
|
|
41
83
|
price: priceInfo.price,
|
|
42
84
|
priceCurrency: resolvedCurrency,
|
|
43
85
|
availability,
|
|
86
|
+
itemCondition,
|
|
87
|
+
...(product.salePrice && product.salePriceEndsAt
|
|
88
|
+
? { priceValidUntil: product.salePriceEndsAt }
|
|
89
|
+
: {}),
|
|
90
|
+
...(shippingDetails.length > 0 ? { shippingDetails } : {}),
|
|
44
91
|
url,
|
|
45
92
|
};
|
|
46
93
|
|
|
@@ -23,6 +23,8 @@ export interface PublicStoreInfo {
|
|
|
23
23
|
requireEmailVerification?: boolean;
|
|
24
24
|
upsell?: StoreInfo['upsell'];
|
|
25
25
|
i18n?: StoreInfo['i18n'];
|
|
26
|
+
/** Real flat-rate/free shipping zones — feeds Product JSON-LD `shippingDetails`. Public by design (merchants display shipping rates openly). */
|
|
27
|
+
shipping?: StoreInfo['shipping'];
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -44,5 +46,6 @@ export function pickPublicStoreInfo(raw: StoreInfo): PublicStoreInfo {
|
|
|
44
46
|
requireEmailVerification: raw.requireEmailVerification,
|
|
45
47
|
upsell: raw.upsell,
|
|
46
48
|
i18n: raw.i18n,
|
|
49
|
+
shipping: raw.shipping,
|
|
47
50
|
};
|
|
48
51
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
@tailwind utilities;
|
|
4
4
|
|
|
5
5
|
/* ---------------------------------------------------------------------------
|
|
6
|
-
Design system — "Atelier" (premium modern
|
|
6
|
+
Design system — "Atelier" (premium modern handcrafted-goods commerce)
|
|
7
7
|
Palette (5 total): warm white / warm ink / deep forest / warm sand (2 tints)
|
|
8
8
|
+ functional destructive. Tokens only — never raw colors in components.
|
|
9
9
|
--------------------------------------------------------------------------- */
|
|
@@ -350,9 +350,10 @@
|
|
|
350
350
|
.cart-bump { animation: cart-bump 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
/* Full-page loader — a
|
|
354
|
-
|
|
355
|
-
.
|
|
353
|
+
/* Full-page loader — a soft pulsing core inside a thin rotating ring
|
|
354
|
+
(Atelier's breathing mark). No iconography, so it fits any store niche.
|
|
355
|
+
Static ring + core under reduced motion; the spin/breathe are additive. */
|
|
356
|
+
.loader-ring {
|
|
356
357
|
position: relative;
|
|
357
358
|
display: flex;
|
|
358
359
|
height: 3.5rem;
|
|
@@ -360,35 +361,40 @@
|
|
|
360
361
|
align-items: center;
|
|
361
362
|
justify-content: center;
|
|
362
363
|
border-radius: 9999px;
|
|
363
|
-
border: 1px solid hsl(var(--primary) / 0.
|
|
364
|
-
box-shadow: inset 0 0 18px hsl(var(--primary) / 0.06);
|
|
364
|
+
border: 1px solid hsl(var(--primary) / 0.15);
|
|
365
365
|
}
|
|
366
|
-
.loader-
|
|
367
|
-
position: absolute;
|
|
368
|
-
inset: 0;
|
|
369
|
-
}
|
|
370
|
-
.loader-orbit-dot::before {
|
|
366
|
+
.loader-ring::before {
|
|
371
367
|
content: '';
|
|
372
368
|
position: absolute;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
369
|
+
inset: -1px;
|
|
370
|
+
border-radius: 9999px;
|
|
371
|
+
border: 1.5px solid transparent;
|
|
372
|
+
border-top-color: hsl(var(--primary) / 0.9);
|
|
373
|
+
}
|
|
374
|
+
.loader-ring-core {
|
|
375
|
+
height: 0.6rem;
|
|
376
|
+
width: 0.6rem;
|
|
378
377
|
border-radius: 9999px;
|
|
379
378
|
background: hsl(var(--primary));
|
|
380
|
-
box-shadow: 0 0 12px hsl(var(--primary) / 0.
|
|
379
|
+
box-shadow: 0 0 12px hsl(var(--primary) / 0.4);
|
|
381
380
|
}
|
|
382
381
|
@media (prefers-reduced-motion: no-preference) {
|
|
383
|
-
.loader-
|
|
384
|
-
animation:
|
|
382
|
+
.loader-ring::before {
|
|
383
|
+
animation: ring-spin 1.4s linear infinite;
|
|
384
|
+
}
|
|
385
|
+
.loader-ring-core {
|
|
386
|
+
animation: ring-breathe 2s ease-in-out infinite;
|
|
385
387
|
}
|
|
386
388
|
.loader-text {
|
|
387
389
|
animation: loader-breathe 2.2s ease-in-out infinite;
|
|
388
390
|
}
|
|
389
|
-
@keyframes
|
|
391
|
+
@keyframes ring-spin {
|
|
390
392
|
to { transform: rotate(360deg); }
|
|
391
393
|
}
|
|
394
|
+
@keyframes ring-breathe {
|
|
395
|
+
0%, 100% { opacity: 0.45; transform: scale(0.85); }
|
|
396
|
+
50% { opacity: 1; transform: scale(1); }
|
|
397
|
+
}
|
|
392
398
|
@keyframes loader-breathe {
|
|
393
399
|
0%, 100% { opacity: 0.55; }
|
|
394
400
|
50% { opacity: 1; }
|