create-brainerce-store 1.65.0 → 1.67.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.
Files changed (49) hide show
  1. package/dist/index.js +2 -2
  2. package/messages/en.json +505 -502
  3. package/messages/he.json +505 -502
  4. package/package.json +1 -1
  5. package/templates/nextjs/base/.env.local.ejs +45 -24
  6. package/templates/nextjs/base/.eslintrc.json +51 -57
  7. package/templates/nextjs/base/AGENTS.md.ejs +107 -81
  8. package/templates/nextjs/base/CLAUDE.md.ejs +118 -92
  9. package/templates/nextjs/base/next.config.ts +103 -86
  10. package/templates/nextjs/base/scripts/fetch-store-info.mjs +104 -97
  11. package/templates/nextjs/base/src/app/agents.md/route.ts +4 -3
  12. package/templates/nextjs/base/src/app/api/auth/me/route.ts +65 -59
  13. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +255 -242
  14. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +311 -308
  15. package/templates/nextjs/base/src/app/blog/page.tsx.ejs +277 -276
  16. package/templates/nextjs/base/src/app/blog/rss.xml/route.ts +4 -3
  17. package/templates/nextjs/base/src/app/category/[slug]/page.tsx +6 -5
  18. package/templates/nextjs/base/src/app/faq/page.tsx.ejs +46 -46
  19. package/templates/nextjs/base/src/app/indexnow-key.txt/route.ts +25 -26
  20. package/templates/nextjs/base/src/app/layout.tsx.ejs +273 -257
  21. package/templates/nextjs/base/src/app/llms.txt/route.ts +4 -3
  22. package/templates/nextjs/base/src/app/opengraph-image.tsx +1 -1
  23. package/templates/nextjs/base/src/app/page.tsx +65 -64
  24. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +92 -92
  25. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +10 -5
  26. package/templates/nextjs/base/src/app/robots.ts +3 -2
  27. package/templates/nextjs/base/src/app/sitemap.ts +4 -3
  28. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +294 -292
  29. package/templates/nextjs/base/src/components/seo/article-json-ld.tsx +60 -59
  30. package/templates/nextjs/base/src/components/seo/category-json-ld.tsx +60 -61
  31. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +16 -2
  32. package/templates/nextjs/base/src/core/lib/brainerce.server.ts +81 -0
  33. package/templates/nextjs/base/src/core/lib/brainerce.ts.ejs +60 -110
  34. package/templates/nextjs/base/src/core/lib/site-url.ts +197 -0
  35. package/templates/nextjs/base/src/ui/product/faq-section.tsx.ejs +46 -0
  36. package/templates/nextjs/base/src/ui/product/review-form.tsx +294 -294
  37. package/templates/nextjs/base/src/ui/product/reviews-section.tsx.ejs +108 -108
  38. package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +301 -285
  39. package/templates/nextjs/designs/atelier/ui/layout/faq-section.tsx +97 -96
  40. package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +142 -141
  41. package/templates/nextjs/designs/atelier/ui/layout/site-header.tsx.ejs +139 -138
  42. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +295 -267
  43. package/templates/nextjs/designs/atelier/ui/product/reviews-section.tsx.ejs +148 -148
  44. package/templates/nextjs/ui-canvas/layout/faq-section.tsx.ejs +72 -71
  45. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +83 -82
  46. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +120 -119
  47. package/templates/nextjs/ui-canvas/product/faq-section.tsx.ejs +54 -0
  48. package/templates/nextjs/ui-canvas/product/review-form.tsx +267 -266
  49. package/templates/nextjs/ui-canvas/product/reviews-section.tsx.ejs +96 -96
@@ -1,96 +1,97 @@
1
- /**
2
- * FAQ accordion (bare skeleton) — fully driven by the merchant's dashboard
3
- * configuration.
4
- *
5
- * The merchant configures FAQs in the Brainerce dashboard under
6
- * Sell → Content → FAQ
7
- *
8
- * Each FAQ row has a `key` (e.g. 'main', 'shipping', 'returns'). Pass the
9
- * pre-fetched payload as `faq`; this component knows nothing about which
10
- * key it came from.
11
- *
12
- * Two render branches:
13
- * 1. `faq` has items → accordion of question/answer pairs
14
- * 2. `faq` is null OR has no items → friendly empty state with a contact
15
- * CTA, so the /faq page never looks broken before the merchant seeds.
16
- *
17
- * Security: FAQ answers may contain merchant-authored HTML — we sanitize
18
- * via `sanitizeHtml` before injecting via dangerouslySetInnerHTML.
19
- */
20
- 'use client';
21
-
22
- import * as React from 'react';
23
- import type { Content } from 'brainerce';
24
- import { useTranslations } from '@/core/lib/translations';
25
- import { sanitizeHtml } from '@/core/lib/sanitize';
26
-
27
- interface FaqSectionProps {
28
- /** Pre-fetched FAQ row. `null` renders the empty-state fallback. */
29
- faq: Content<'FAQ'> | null;
30
- }
31
-
32
- export function FaqSection({ faq }: FaqSectionProps) {
33
- const t = useTranslations('content');
34
-
35
- const items = faq?.data?.items ?? [];
36
- const heading = faq?.name || t('faqTitle');
37
-
38
- // Empty state — runs when the merchant hasn't created a FAQ row yet,
39
- // or the row exists but contains no items.
40
- if (!faq || items.length === 0) {
41
- return (
42
- <section className="container-page py-16 lg:py-24">
43
- <div className="card mx-auto flex max-w-lg flex-col items-center gap-3 px-8 py-14 text-center">
44
- <h1 className="text-3xl">{heading}</h1>
45
- <p className="text-muted-foreground">
46
- <strong className="mb-1 block font-semibold text-foreground">
47
- {t('faqEmptyTitle')}
48
- </strong>
49
- {t('faqEmptyBody')}
50
- </p>
51
- <a href="/contact" className="btn-primary btn-md mt-3">
52
- {t('faqContactCta')}
53
- </a>
54
- </div>
55
- </section>
56
- );
57
- }
58
-
59
- return (
60
- <section className="container-page max-w-3xl py-14 lg:py-20">
61
- <h1 className="mb-8 text-center text-3xl sm:text-4xl">{heading}</h1>
62
- <ul className="space-y-3">
63
- {items.map((item, idx) => (
64
- <li key={idx}>
65
- <details open={idx === 0} className="group card overflow-hidden">
66
- <summary className="flex cursor-pointer list-none items-center justify-between gap-4 px-5 py-4 font-sans text-[15px] font-semibold text-foreground transition-colors hover:bg-secondary/60 [&::-webkit-details-marker]:hidden">
67
- {item.question}
68
- <span
69
- aria-hidden="true"
70
- className="shrink-0 text-muted-foreground transition-transform duration-200 group-open:rotate-180"
71
- >
72
- <svg
73
- width="20"
74
- height="20"
75
- viewBox="0 0 24 24"
76
- fill="none"
77
- stroke="currentColor"
78
- strokeWidth="1.75"
79
- strokeLinecap="round"
80
- strokeLinejoin="round"
81
- >
82
- <path d="m6 9 6 6 6-6" />
83
- </svg>
84
- </span>
85
- </summary>
86
- <div
87
- className="prose-store border-t px-5 py-4"
88
- dangerouslySetInnerHTML={{ __html: sanitizeHtml(item.answer) }}
89
- />
90
- </details>
91
- </li>
92
- ))}
93
- </ul>
94
- </section>
95
- );
96
- }
1
+ /**
2
+ * FAQ accordion (bare skeleton) — fully driven by the merchant's dashboard
3
+ * configuration.
4
+ *
5
+ * The merchant configures FAQs in the Brainerce dashboard under
6
+ * Sell → Content → FAQ
7
+ *
8
+ * Each FAQ row has a `key` (e.g. 'main', 'shipping', 'returns'). Pass the
9
+ * pre-fetched payload as `faq`; this component knows nothing about which
10
+ * key it came from.
11
+ *
12
+ * Two render branches:
13
+ * 1. `faq` has items → accordion of question/answer pairs
14
+ * 2. `faq` is null OR has no items → friendly empty state with a contact
15
+ * CTA, so the /faq page never looks broken before the merchant seeds.
16
+ *
17
+ * Security: FAQ answers may contain merchant-authored HTML — we sanitize
18
+ * via `sanitizeHtml` before injecting via dangerouslySetInnerHTML.
19
+ */
20
+ 'use client';
21
+
22
+ import * as React from 'react';
23
+ import { Link } from '@/core/lib/navigation';
24
+ import type { Content } from 'brainerce';
25
+ import { useTranslations } from '@/core/lib/translations';
26
+ import { sanitizeHtml } from '@/core/lib/sanitize';
27
+
28
+ interface FaqSectionProps {
29
+ /** Pre-fetched FAQ row. `null` renders the empty-state fallback. */
30
+ faq: Content<'FAQ'> | null;
31
+ }
32
+
33
+ export function FaqSection({ faq }: FaqSectionProps) {
34
+ const t = useTranslations('content');
35
+
36
+ const items = faq?.data?.items ?? [];
37
+ const heading = faq?.name || t('faqTitle');
38
+
39
+ // Empty state — runs when the merchant hasn't created a FAQ row yet,
40
+ // or the row exists but contains no items.
41
+ if (!faq || items.length === 0) {
42
+ return (
43
+ <section className="container-page py-16 lg:py-24">
44
+ <div className="card mx-auto flex max-w-lg flex-col items-center gap-3 px-8 py-14 text-center">
45
+ <h1 className="text-3xl">{heading}</h1>
46
+ <p className="text-muted-foreground">
47
+ <strong className="text-foreground mb-1 block font-semibold">
48
+ {t('faqEmptyTitle')}
49
+ </strong>
50
+ {t('faqEmptyBody')}
51
+ </p>
52
+ <Link href="/contact" className="btn-primary btn-md mt-3">
53
+ {t('faqContactCta')}
54
+ </Link>
55
+ </div>
56
+ </section>
57
+ );
58
+ }
59
+
60
+ return (
61
+ <section className="container-page max-w-3xl py-14 lg:py-20">
62
+ <h1 className="mb-8 text-center text-3xl sm:text-4xl">{heading}</h1>
63
+ <ul className="space-y-3">
64
+ {items.map((item, idx) => (
65
+ <li key={idx}>
66
+ <details open={idx === 0} className="card group overflow-hidden">
67
+ <summary className="text-foreground hover:bg-secondary/60 flex cursor-pointer list-none items-center justify-between gap-4 px-5 py-4 font-sans text-[15px] font-semibold transition-colors [&::-webkit-details-marker]:hidden">
68
+ {item.question}
69
+ <span
70
+ aria-hidden="true"
71
+ className="text-muted-foreground shrink-0 transition-transform duration-200 group-open:rotate-180"
72
+ >
73
+ <svg
74
+ width="20"
75
+ height="20"
76
+ viewBox="0 0 24 24"
77
+ fill="none"
78
+ stroke="currentColor"
79
+ strokeWidth="1.75"
80
+ strokeLinecap="round"
81
+ strokeLinejoin="round"
82
+ >
83
+ <path d="m6 9 6 6 6-6" />
84
+ </svg>
85
+ </span>
86
+ </summary>
87
+ <div
88
+ className="prose-store border-t px-5 py-4"
89
+ dangerouslySetInnerHTML={{ __html: sanitizeHtml(item.answer) }}
90
+ />
91
+ </details>
92
+ </li>
93
+ ))}
94
+ </ul>
95
+ </section>
96
+ );
97
+ }
@@ -1,141 +1,142 @@
1
- /**
2
- * Storefront footer — driven by the merchant's dashboard configuration
3
- * (Sell → Content → Footer), rendered as a deep-forest "signature" band:
4
- * brand block + tagline + social, merchant link columns, copyright bar.
5
- *
6
- * API contract:
7
- * GET → client.content.footer.get('main', locale) → Content<'FOOTER'> | null
8
- * Returns null on 404 — the fallback branch renders the same designed
9
- * chrome with essential storefront links so the page never looks broken.
10
- */
11
- import * as React from 'react';
12
- import type { Content } from 'brainerce';
13
- <% if (i18nEnabled) { %>
14
- import { getMessages, defaultLocale } from '@/i18n';
15
- <% } else { %>
16
- import { messages as staticMessages, defaultLocale } from '@/i18n';
17
- <% } %>
18
- import { IconSocial, IconShield } from '@/ui/shared/icons';
19
- import { resolveNavUrl } from '@/ui/layout/nav-url';
20
-
21
- interface SiteFooterProps {
22
- /** Pre-fetched footer payload (server-side). `null` triggers fallback rendering. */
23
- footer: Content<'FOOTER'> | null;
24
- /** Store name shown in the brand block + fallback copyright. */
25
- storeName?: string;
26
- /** Store locale for the translation-key copy (server component). */
27
- locale?: string;
28
- }
29
-
30
- export async function SiteFooter({ footer, storeName, locale = defaultLocale }: SiteFooterProps) {
31
- <% if (i18nEnabled) { %>
32
- const messages = await getMessages(locale);
33
- <% } else { %>
34
- const messages = staticMessages;
35
- <% } %>
36
- const t = (messages.footer ?? {}) as Record<string, string>;
37
-
38
- const data = footer?.data;
39
- const columns = data?.columns ?? [];
40
- const social = data?.social ?? [];
41
- const year = new Date().getFullYear();
42
- const brandLabel = storeName ?? 'Store';
43
-
44
- const fallbackLinks = [
45
- { url: '/products', label: t.linkProducts },
46
- { url: '/faq', label: t.linkFaq },
47
- { url: '/contact', label: t.linkContact },
48
- { url: '/cart', label: t.linkCart },
49
- ];
50
-
51
- return (
52
- <footer className="mt-auto bg-primary text-primary-foreground">
53
- <div className="container-page grid gap-10 py-14 sm:grid-cols-2 lg:grid-cols-4 lg:py-16">
54
- {/* Brand block */}
55
- <div className="sm:col-span-2 lg:col-span-2 lg:pe-16">
56
- <a href="/" className="font-display text-2xl font-semibold">
57
- {brandLabel}
58
- </a>
59
- <p className="mt-3 max-w-sm text-sm leading-6 text-primary-foreground/70">
60
- {t.tagline}
61
- </p>
62
-
63
- {social.length > 0 && (
64
- <div className="mt-6">
65
- <p className="mb-3 text-xs font-semibold uppercase tracking-widest text-primary-foreground/60">
66
- {t.followUs}
67
- </p>
68
- <ul className="flex flex-wrap items-center gap-2">
69
- {social.map((entry, idx) => (
70
- <li key={`${entry.platform}-${idx}`}>
71
- <a
72
- href={entry.url}
73
- target="_blank"
74
- rel="noopener noreferrer"
75
- aria-label={entry.platform}
76
- className="inline-flex h-10 w-10 items-center justify-center rounded-full border border-primary-foreground/25 text-primary-foreground/85 transition-colors hover:bg-primary-foreground hover:text-primary"
77
- >
78
- <IconSocial platform={entry.platform} size={20} />
79
- </a>
80
- </li>
81
- ))}
82
- </ul>
83
- </div>
84
- )}
85
- </div>
86
-
87
- {/* Merchant link columns (or essential fallback links) */}
88
- {columns.length > 0 ? (
89
- columns.map((col, idx) => (
90
- <nav key={`${col.title}-${idx}`} aria-label={col.title}>
91
- <h3 className="mb-4 font-sans text-sm font-semibold text-primary-foreground">
92
- {col.title}
93
- </h3>
94
- <ul className="space-y-2.5">
95
- {col.links.map((link, linkIdx) => (
96
- <li key={`${link.url}-${linkIdx}`}>
97
- <a
98
- href={resolveNavUrl(link.url)}
99
- className="text-sm text-primary-foreground/70 transition-colors hover:text-primary-foreground"
100
- >
101
- {link.label}
102
- </a>
103
- </li>
104
- ))}
105
- </ul>
106
- </nav>
107
- ))
108
- ) : (
109
- <nav aria-label={t.quickLinksTitle}>
110
- <h3 className="mb-4 font-sans text-sm font-semibold text-primary-foreground">
111
- {t.quickLinksTitle}
112
- </h3>
113
- <ul className="space-y-2.5">
114
- {fallbackLinks.map((link) => (
115
- <li key={link.url}>
116
- <a
117
- href={link.url}
118
- className="text-sm text-primary-foreground/70 transition-colors hover:text-primary-foreground"
119
- >
120
- {link.label}
121
- </a>
122
- </li>
123
- ))}
124
- </ul>
125
- </nav>
126
- )}
127
- </div>
128
-
129
- {/* Bottom bar */}
130
- <div className="border-t border-primary-foreground/15">
131
- <div className="container-page flex flex-col items-center justify-between gap-3 py-5 text-xs text-primary-foreground/60 sm:flex-row">
132
- <p>{data?.copyright ?? ${year} ${brandLabel}. ${messages.common?.allRightsReserved ?? ''}`}</p>
133
- <p className="inline-flex items-center gap-1.5">
134
- <IconShield size={16} />
135
- {t.securePayments}
136
- </p>
137
- </div>
138
- </div>
139
- </footer>
140
- );
141
- }
1
+ /**
2
+ * Storefront footer — driven by the merchant's dashboard configuration
3
+ * (Sell → Content → Footer), rendered as a deep-forest "signature" band:
4
+ * brand block + tagline + social, merchant link columns, copyright bar.
5
+ *
6
+ * API contract:
7
+ * GET → client.content.footer.get('main', locale) → Content<'FOOTER'> | null
8
+ * Returns null on 404 — the fallback branch renders the same designed
9
+ * chrome with essential storefront links so the page never looks broken.
10
+ */
11
+ import * as React from 'react';
12
+ import { Link } from '@/core/lib/navigation';
13
+ import type { Content } from 'brainerce';
14
+ <% if (i18nEnabled) { %>
15
+ import { getMessages, defaultLocale } from '@/i18n';
16
+ <% } else { %>
17
+ import { messages as staticMessages, defaultLocale } from '@/i18n';
18
+ <% } %>
19
+ import { IconSocial, IconShield } from '@/ui/shared/icons';
20
+ import { resolveNavUrl } from '@/ui/layout/nav-url';
21
+
22
+ interface SiteFooterProps {
23
+ /** Pre-fetched footer payload (server-side). `null` triggers fallback rendering. */
24
+ footer: Content<'FOOTER'> | null;
25
+ /** Store name shown in the brand block + fallback copyright. */
26
+ storeName?: string;
27
+ /** Store locale for the translation-key copy (server component). */
28
+ locale?: string;
29
+ }
30
+
31
+ export async function SiteFooter({ footer, storeName, locale = defaultLocale }: SiteFooterProps) {
32
+ <% if (i18nEnabled) { %>
33
+ const messages = await getMessages(locale);
34
+ <% } else { %>
35
+ const messages = staticMessages;
36
+ <% } %>
37
+ const t = (messages.footer ?? {}) as Record<string, string>;
38
+
39
+ const data = footer?.data;
40
+ const columns = data?.columns ?? [];
41
+ const social = data?.social ?? [];
42
+ const year = new Date().getFullYear();
43
+ const brandLabel = storeName ?? 'Store';
44
+
45
+ const fallbackLinks = [
46
+ { url: '/products', label: t.linkProducts },
47
+ { url: '/faq', label: t.linkFaq },
48
+ { url: '/contact', label: t.linkContact },
49
+ { url: '/cart', label: t.linkCart },
50
+ ];
51
+
52
+ return (
53
+ <footer className="mt-auto bg-primary text-primary-foreground">
54
+ <div className="container-page grid gap-10 py-14 sm:grid-cols-2 lg:grid-cols-4 lg:py-16">
55
+ {/* Brand block */}
56
+ <div className="sm:col-span-2 lg:col-span-2 lg:pe-16">
57
+ <Link href="/" className="font-display text-2xl font-semibold">
58
+ {brandLabel}
59
+ </Link>
60
+ <p className="mt-3 max-w-sm text-sm leading-6 text-primary-foreground/70">
61
+ {t.tagline}
62
+ </p>
63
+
64
+ {social.length > 0 && (
65
+ <div className="mt-6">
66
+ <p className="mb-3 text-xs font-semibold uppercase tracking-widest text-primary-foreground/60">
67
+ {t.followUs}
68
+ </p>
69
+ <ul className="flex flex-wrap items-center gap-2">
70
+ {social.map((entry, idx) => (
71
+ <li key={`${entry.platform}-${idx}`}>
72
+ <a
73
+ href={entry.url}
74
+ target="_blank"
75
+ rel="noopener noreferrer"
76
+ aria-label={entry.platform}
77
+ className="inline-flex h-10 w-10 items-center justify-center rounded-full border border-primary-foreground/25 text-primary-foreground/85 transition-colors hover:bg-primary-foreground hover:text-primary"
78
+ >
79
+ <IconSocial platform={entry.platform} size={20} />
80
+ </a>
81
+ </li>
82
+ ))}
83
+ </ul>
84
+ </div>
85
+ )}
86
+ </div>
87
+
88
+ {/* Merchant link columns (or essential fallback links) */}
89
+ {columns.length > 0 ? (
90
+ columns.map((col, idx) => (
91
+ <nav key={`${col.title}-${idx}`} aria-label={col.title}>
92
+ <h3 className="mb-4 font-sans text-sm font-semibold text-primary-foreground">
93
+ {col.title}
94
+ </h3>
95
+ <ul className="space-y-2.5">
96
+ {col.links.map((link, linkIdx) => (
97
+ <li key={`${link.url}-${linkIdx}`}>
98
+ <a
99
+ href={resolveNavUrl(link.url)}
100
+ className="text-sm text-primary-foreground/70 transition-colors hover:text-primary-foreground"
101
+ >
102
+ {link.label}
103
+ </a>
104
+ </li>
105
+ ))}
106
+ </ul>
107
+ </nav>
108
+ ))
109
+ ) : (
110
+ <nav aria-label={t.quickLinksTitle}>
111
+ <h3 className="mb-4 font-sans text-sm font-semibold text-primary-foreground">
112
+ {t.quickLinksTitle}
113
+ </h3>
114
+ <ul className="space-y-2.5">
115
+ {fallbackLinks.map((link) => (
116
+ <li key={link.url}>
117
+ <a
118
+ href={link.url}
119
+ className="text-sm text-primary-foreground/70 transition-colors hover:text-primary-foreground"
120
+ >
121
+ {link.label}
122
+ </a>
123
+ </li>
124
+ ))}
125
+ </ul>
126
+ </nav>
127
+ )}
128
+ </div>
129
+
130
+ {/* Bottom bar */}
131
+ <div className="border-t border-primary-foreground/15">
132
+ <div className="container-page flex flex-col items-center justify-between gap-3 py-5 text-xs text-primary-foreground/60 sm:flex-row">
133
+ <p>{data?.copyright ?? ${year} ${brandLabel}. ${messages.common?.allRightsReserved ?? ''}`}</p>
134
+ <p className="inline-flex items-center gap-1.5">
135
+ <IconShield size={16} />
136
+ {t.securePayments}
137
+ </p>
138
+ </div>
139
+ </div>
140
+ </footer>
141
+ );
142
+ }