create-brainerce-store 1.66.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 (46) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/templates/nextjs/base/.env.local.ejs +45 -24
  4. package/templates/nextjs/base/.eslintrc.json +51 -57
  5. package/templates/nextjs/base/AGENTS.md.ejs +107 -81
  6. package/templates/nextjs/base/CLAUDE.md.ejs +118 -92
  7. package/templates/nextjs/base/next.config.ts +103 -86
  8. package/templates/nextjs/base/scripts/fetch-store-info.mjs +104 -97
  9. package/templates/nextjs/base/src/app/agents.md/route.ts +4 -3
  10. package/templates/nextjs/base/src/app/api/auth/me/route.ts +65 -59
  11. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +255 -242
  12. package/templates/nextjs/base/src/app/blog/[slug]/page.tsx.ejs +311 -308
  13. package/templates/nextjs/base/src/app/blog/page.tsx.ejs +277 -276
  14. package/templates/nextjs/base/src/app/blog/rss.xml/route.ts +4 -3
  15. package/templates/nextjs/base/src/app/category/[slug]/page.tsx +6 -5
  16. package/templates/nextjs/base/src/app/faq/page.tsx.ejs +46 -46
  17. package/templates/nextjs/base/src/app/indexnow-key.txt/route.ts +25 -26
  18. package/templates/nextjs/base/src/app/layout.tsx.ejs +273 -257
  19. package/templates/nextjs/base/src/app/llms.txt/route.ts +4 -3
  20. package/templates/nextjs/base/src/app/opengraph-image.tsx +1 -1
  21. package/templates/nextjs/base/src/app/page.tsx +65 -64
  22. package/templates/nextjs/base/src/app/pages/[slug]/page.tsx.ejs +92 -92
  23. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +6 -5
  24. package/templates/nextjs/base/src/app/robots.ts +3 -2
  25. package/templates/nextjs/base/src/app/sitemap.ts +4 -3
  26. package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +294 -292
  27. package/templates/nextjs/base/src/components/seo/article-json-ld.tsx +60 -59
  28. package/templates/nextjs/base/src/components/seo/category-json-ld.tsx +60 -61
  29. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +2 -1
  30. package/templates/nextjs/base/src/core/lib/brainerce.server.ts +81 -0
  31. package/templates/nextjs/base/src/core/lib/brainerce.ts.ejs +60 -110
  32. package/templates/nextjs/base/src/core/lib/site-url.ts +197 -0
  33. package/templates/nextjs/base/src/ui/product/review-form.tsx +294 -294
  34. package/templates/nextjs/base/src/ui/product/reviews-section.tsx.ejs +108 -108
  35. package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +301 -285
  36. package/templates/nextjs/designs/atelier/ui/layout/faq-section.tsx +97 -96
  37. package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +142 -141
  38. package/templates/nextjs/designs/atelier/ui/layout/site-header.tsx.ejs +139 -138
  39. package/templates/nextjs/designs/atelier/ui/product/review-form.tsx +295 -267
  40. package/templates/nextjs/designs/atelier/ui/product/reviews-section.tsx.ejs +148 -148
  41. package/templates/nextjs/ui-canvas/layout/faq-section.tsx.ejs +72 -71
  42. package/templates/nextjs/ui-canvas/layout/site-footer.tsx.ejs +83 -82
  43. package/templates/nextjs/ui-canvas/layout/site-header.tsx.ejs +120 -119
  44. package/templates/nextjs/ui-canvas/product/faq-section.tsx.ejs +54 -0
  45. package/templates/nextjs/ui-canvas/product/review-form.tsx +267 -266
  46. package/templates/nextjs/ui-canvas/product/reviews-section.tsx.ejs +96 -96
@@ -1,96 +1,96 @@
1
- import type { ProductReview } from 'brainerce';
2
- import { getServerClient } from '@/core/lib/brainerce';
3
- <% if (i18nEnabled) { %>import { getMessages, defaultLocale } from '@/i18n';<% } else { %>import { defaultLocale, messages } from '@/i18n';<% } %>
4
- import { ReviewForm } from './review-form';
5
-
6
- // Server component — it renders before any client i18n context exists, so the
7
- // wrapper strings (title / empty state / verified badge) are read straight
8
- // from the `reviews` namespace in messages/, keyed by the store locale.
9
- type ReviewStrings = Record<string, string>;
10
-
11
- <% if (i18nEnabled) { %>async function getReviewStrings(locale: string): Promise<ReviewStrings> {
12
- return ((await getMessages(locale)).reviews ?? {}) as ReviewStrings;
13
- }<% } else { %>async function getReviewStrings(_locale: string): Promise<ReviewStrings> {
14
- return messages.reviews as ReviewStrings;
15
- }<% } %>
16
-
17
- interface ReviewsSectionProps {
18
- productId: string;
19
- initialReviews?: ProductReview[];
20
- locale?: string;
21
- /** Where to send users back to after submit (defaults to the current product URL). */
22
- returnUrl?: string;
23
- }
24
-
25
- /**
26
- * Renders the visible reviews for a product plus a submit form.
27
- *
28
- * Server component — fetches with the SDK on the server so reviews are in
29
- * the initial HTML payload (good for SEO; JSON-LD on the same page already
30
- * carries `aggregateRating` when reviewCount > 0).
31
- */
32
- export async function ReviewsSection({
33
- productId,
34
- initialReviews,
35
- locale = defaultLocale,
36
- }: ReviewsSectionProps) {
37
- const t = await getReviewStrings(locale);
38
- let reviews: ProductReview[] = initialReviews ?? [];
39
-
40
- if (!initialReviews) {
41
- try {
42
- const result = await getServerClient().listProductReviews(productId, { page: 1, limit: 20 });
43
- reviews = result.data;
44
- } catch {
45
- // Review listing disabled at store level or network error — render the form anyway.
46
- reviews = [];
47
- }
48
- }
49
-
50
- return (
51
- <section aria-labelledby="reviews-heading">
52
- {/* DESIGN ME — product reviews: server-fetched review list (SDK listProductReviews) + eligibility-aware submit form. Compose with the shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons. */}
53
- <h2 id="reviews-heading">{t.title}</h2>
54
-
55
- {reviews.length === 0 ? (
56
- <p>{t.noReviews}</p>
57
- ) : (
58
- <ul>
59
- {reviews.map((review) => (
60
- <ReviewCard key={review.id} review={review} verifiedLabel={t.verifiedPurchase} />
61
- ))}
62
- </ul>
63
- )}
64
-
65
- <ReviewForm productId={productId} />
66
- </section>
67
- );
68
- }
69
-
70
- function ReviewCard({ review, verifiedLabel }: { review: ProductReview; verifiedLabel: string }) {
71
- return (
72
- <li>
73
- <article>
74
- <header className="flex flex-wrap items-center gap-2">
75
- <Stars rating={review.rating} />
76
- <span>{review.authorName}</span>
77
- {review.verifiedPurchase && <span>{verifiedLabel}</span>}
78
- <time dateTime={review.createdAt}>{new Date(review.createdAt).toLocaleDateString()}</time>
79
- </header>
80
- {review.body && <p className="whitespace-pre-line break-words">{review.body}</p>}
81
- </article>
82
- </li>
83
- );
84
- }
85
-
86
- function Stars({ rating }: { rating: number }) {
87
- return (
88
- <span aria-label={`${rating} of 5 stars`}>
89
- {[1, 2, 3, 4, 5].map((n) => (
90
- <span key={n} aria-hidden="true">
91
- {n <= rating ? '★' : '☆'}
92
- </span>
93
- ))}
94
- </span>
95
- );
96
- }
1
+ import type { ProductReview } from 'brainerce';
2
+ import { getServerClient } from '@/core/lib/brainerce.server';
3
+ <% if (i18nEnabled) { %>import { getMessages, defaultLocale } from '@/i18n';<% } else { %>import { defaultLocale, messages } from '@/i18n';<% } %>
4
+ import { ReviewForm } from './review-form';
5
+
6
+ // Server component — it renders before any client i18n context exists, so the
7
+ // wrapper strings (title / empty state / verified badge) are read straight
8
+ // from the `reviews` namespace in messages/, keyed by the store locale.
9
+ type ReviewStrings = Record<string, string>;
10
+
11
+ <% if (i18nEnabled) { %>async function getReviewStrings(locale: string): Promise<ReviewStrings> {
12
+ return ((await getMessages(locale)).reviews ?? {}) as ReviewStrings;
13
+ }<% } else { %>async function getReviewStrings(_locale: string): Promise<ReviewStrings> {
14
+ return messages.reviews as ReviewStrings;
15
+ }<% } %>
16
+
17
+ interface ReviewsSectionProps {
18
+ productId: string;
19
+ initialReviews?: ProductReview[];
20
+ locale?: string;
21
+ /** Where to send users back to after submit (defaults to the current product URL). */
22
+ returnUrl?: string;
23
+ }
24
+
25
+ /**
26
+ * Renders the visible reviews for a product plus a submit form.
27
+ *
28
+ * Server component — fetches with the SDK on the server so reviews are in
29
+ * the initial HTML payload (good for SEO; JSON-LD on the same page already
30
+ * carries `aggregateRating` when reviewCount > 0).
31
+ */
32
+ export async function ReviewsSection({
33
+ productId,
34
+ initialReviews,
35
+ locale = defaultLocale,
36
+ }: ReviewsSectionProps) {
37
+ const t = await getReviewStrings(locale);
38
+ let reviews: ProductReview[] = initialReviews ?? [];
39
+
40
+ if (!initialReviews) {
41
+ try {
42
+ const result = await (await getServerClient()).listProductReviews(productId, { page: 1, limit: 20 });
43
+ reviews = result.data;
44
+ } catch {
45
+ // Review listing disabled at store level or network error — render the form anyway.
46
+ reviews = [];
47
+ }
48
+ }
49
+
50
+ return (
51
+ <section aria-labelledby="reviews-heading">
52
+ {/* DESIGN ME — product reviews: server-fetched review list (SDK listProductReviews) + eligibility-aware submit form. Compose with the shadcn/ui primitives in src/components/ui (Button, Card, Badge, Input, Select, Accordion, Dialog, Skeleton, ...) + lucide-react icons. */}
53
+ <h2 id="reviews-heading">{t.title}</h2>
54
+
55
+ {reviews.length === 0 ? (
56
+ <p>{t.noReviews}</p>
57
+ ) : (
58
+ <ul>
59
+ {reviews.map((review) => (
60
+ <ReviewCard key={review.id} review={review} verifiedLabel={t.verifiedPurchase} />
61
+ ))}
62
+ </ul>
63
+ )}
64
+
65
+ <ReviewForm productId={productId} />
66
+ </section>
67
+ );
68
+ }
69
+
70
+ function ReviewCard({ review, verifiedLabel }: { review: ProductReview; verifiedLabel: string }) {
71
+ return (
72
+ <li>
73
+ <article>
74
+ <header className="flex flex-wrap items-center gap-2">
75
+ <Stars rating={review.rating} />
76
+ <span>{review.authorName}</span>
77
+ {review.verifiedPurchase && <span>{verifiedLabel}</span>}
78
+ <time dateTime={review.createdAt}>{new Date(review.createdAt).toLocaleDateString()}</time>
79
+ </header>
80
+ {review.body && <p className="whitespace-pre-line break-words">{review.body}</p>}
81
+ </article>
82
+ </li>
83
+ );
84
+ }
85
+
86
+ function Stars({ rating }: { rating: number }) {
87
+ return (
88
+ <span aria-label={`${rating} of 5 stars`}>
89
+ {[1, 2, 3, 4, 5].map((n) => (
90
+ <span key={n} aria-hidden="true">
91
+ {n <= rating ? '★' : '☆'}
92
+ </span>
93
+ ))}
94
+ </span>
95
+ );
96
+ }