@shop-on/create-theme 0.9.0 → 0.11.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 (48) hide show
  1. package/dist/cli.mjs +1 -2
  2. package/dist/index.d.mts +1 -3
  3. package/dist/index.mjs +1 -2
  4. package/package.json +3 -3
  5. package/template/.claude/skills/theme-dev/SKILL.md +4 -4
  6. package/template/.claude/skills/theme-dev/recipes/concepts.md +2 -2
  7. package/template/.claude/skills/theme-dev/recipes/custom-sections.md +28 -226
  8. package/template/.claude/skills/theme-dev/recipes/customer-auth.md +2 -1
  9. package/template/.claude/skills/theme-dev/recipes/data-fetching.md +2 -2
  10. package/template/.claude/skills/theme-dev/recipes/input-settings.md +5 -6
  11. package/template/.claude/skills/theme-dev/recipes/locales.md +1 -1
  12. package/template/.claude/skills/theme-dev/recipes/picker-data.md +2 -2
  13. package/template/.env.example +2 -3
  14. package/template/.oxfmtrc.json +0 -1
  15. package/template/package.json +21 -22
  16. package/template/src/ai/guide.md +25 -0
  17. package/template/src/blocks/custom-block.json +4 -0
  18. package/template/src/blocks/custom-block.test.ts +16 -0
  19. package/template/src/blocks/custom-block.tsx +26 -0
  20. package/template/src/lib/i18n.server.ts +2 -2
  21. package/template/src/lib/i18n.ts +9 -0
  22. package/template/src/lib/listing-search.ts +7 -12
  23. package/template/src/lib/use-analytics.ts +11 -11
  24. package/template/src/locales/en.default.json +4 -0
  25. package/template/src/locales/en.default.schema.json +16 -2
  26. package/template/src/locales/mn.default.json +4 -0
  27. package/template/src/locales/mn.default.schema.json +16 -2
  28. package/template/src/route-adapter.tsx +0 -2
  29. package/template/src/routeTree.gen.ts +22 -0
  30. package/template/src/routes/__root.tsx +2 -2
  31. package/template/src/routes/robots[.]txt.tsx +5 -5
  32. package/template/src/routes/sitemap[.]xml.tsx +5 -4
  33. package/template/src/routes/{-$locale}/checkout.tsx +13 -8
  34. package/template/src/routes/{-$locale}/collections/index.tsx +1 -1
  35. package/template/src/routes/{-$locale}/orders/find.tsx +13 -0
  36. package/template/src/sections/custom-section.json +39 -0
  37. package/template/src/sections/custom-section.test.ts +14 -0
  38. package/template/src/sections/custom-section.tsx +73 -0
  39. package/template/src/sections/hero.json +6 -1
  40. package/template/src/sections/main-collection.test.tsx +21 -7
  41. package/template/src/sections/main-product.json +1 -0
  42. package/template/src/sections/main-product.tsx +15 -0
  43. package/template/src/server/i18n.server.test.ts +2 -2
  44. package/template/src/server/i18n.server.ts +7 -19
  45. package/template/src/server/settings.ts +26 -7
  46. package/template/src/server/template-loader.ts +2 -2
  47. package/template/tsconfig.json +0 -7
  48. package/template/src/server/checkout-redirect.ts +0 -21
@@ -0,0 +1,26 @@
1
+ import { useTranslations } from "@shop-on/i18n";
2
+ import { CustomSectionHtml } from "@shop-on/theme-react/custom-section-html";
3
+
4
+ // A block an AI assistant wrote inside a section that lists `custom-block`
5
+ // (main-product's info column): rendered on the server by the same pass as a
6
+ // custom section, arriving as `customHtml`. No shell of its own: the section
7
+ // around it owns the width and spacing.
8
+ export default function CustomBlock({
9
+ customHtml = null,
10
+ customError = null,
11
+ }: {
12
+ customHtml?: string | null;
13
+ customError?: string | null;
14
+ }) {
15
+ const t = useTranslations("custom_section");
16
+
17
+ // Editor-only by construction: the pass writes `customError` only when the
18
+ // request carries an editor `sid`.
19
+ if (customError)
20
+ return (
21
+ <p className="rounded-lg border border-border p-4 text-sm text-muted">
22
+ {t("block_error")}: {customError}
23
+ </p>
24
+ );
25
+ return <CustomSectionHtml html={customHtml ?? ""} />;
26
+ }
@@ -16,8 +16,8 @@ const { handleLocaleMiddleware } = createI18nServer(
16
16
 
17
17
  export { handleLocaleMiddleware };
18
18
 
19
- // Snapshot the shop's locale config (primary + published extras, as the
20
- // storefront-scoped API already filters them) for the sync i18n call sites.
19
+ // Snapshot the shop's locale config (primary + published extras, as
20
+ // `fetchShopInfo` already filters them) for the sync i18n call sites.
21
21
  // `fetchShopInfo` is memoTTL-cached, so this is a no-op-cheap await on warm
22
22
  // requests. Failures keep the previous snapshot (or the build-time fallback
23
23
  // on a cold process) rather than failing the request.
@@ -37,3 +37,12 @@ export function publicPath(pathname: string): string {
37
37
  if (!getCurrentLocale()) return pathname;
38
38
  return localizeUrl(new URL(pathname, "http://internal")).pathname;
39
39
  }
40
+
41
+ /** The public path for a site path in an EXPLICIT content locale (undefined on
42
+ * the primary one), for server code that holds the request's locale rather
43
+ * than the ambient one: the custom-section pass's `localizePath`. The raw
44
+ * string is prefixed, so a query survives. */
45
+ export function localizedPath(path: string, locale: string | undefined): string {
46
+ if (!locale) return path;
47
+ return `/${locale}${path === "/" ? "" : path}`;
48
+ }
@@ -13,12 +13,12 @@
13
13
  import type { ParsedBlogSearch, ParsedListingSearch } from "@shop-on/theme-routes";
14
14
  import {
15
15
  asParam,
16
+ type ListingFilters,
16
17
  narrowedListingPath,
17
18
  parseListingFilters,
18
- toFilterInput,
19
19
  } from "@shop-on/theme-runtime/listing-filters";
20
- import type { CollectionFilterInput, CollectionSort } from "@shop-on/theme-server/collection";
21
- import type { ProductSearchFilterInput, ProductSearchSort } from "@shop-on/theme-server/search";
20
+ import type { CollectionSort } from "@shop-on/theme-server/collection";
21
+ import type { ProductSearchSort } from "@shop-on/theme-server/search";
22
22
 
23
23
  /** The listing's implicit ordering when `?sort=` is absent. */
24
24
  export const DEFAULT_COLLECTION_SORT: CollectionSort = "FEATURED";
@@ -74,10 +74,9 @@ export function parseCollectionSearch(search: unknown): ParsedListingSearch {
74
74
  };
75
75
  }
76
76
 
77
- /** URL state → the GraphQL filter input. `undefined` when nothing is applied, so
78
- * the resolver short-circuits to the unfiltered base scope. */
79
- export function searchToFilterInput(state: ParsedListingSearch): CollectionFilterInput | undefined {
80
- return toFilterInput(state);
77
+ /** URL state → a listing's `filter`: the ticked facet values and the price bounds. */
78
+ export function searchToFilterInput(state: ParsedListingSearch): ListingFilters {
79
+ return { filters: state.filters, price_min: state.price_min, price_max: state.price_max };
81
80
  }
82
81
 
83
82
  /** Self-canonical for a narrowed listing view — filters, sort and page in the
@@ -97,11 +96,7 @@ export function parseProductSearch(search: unknown): ParsedListingSearch & { q?:
97
96
  }
98
97
 
99
98
  /** /search narrows on the same grammar as a collection. */
100
- export function searchToProductFilterInput(
101
- state: ParsedListingSearch & { q?: string },
102
- ): ProductSearchFilterInput | undefined {
103
- return toFilterInput(state);
104
- }
99
+ export const searchToProductFilterInput = searchToFilterInput;
105
100
 
106
101
  export function parseBlogSearch(search: unknown): ParsedBlogSearch {
107
102
  const raw = (search ?? {}) as Record<string, unknown>;
@@ -2,11 +2,11 @@ import { type MouseEvent, useEffect, useLayoutEffect, useRef, useState } from "r
2
2
  import {
3
3
  ensureVisit,
4
4
  type ProductListType,
5
- toInt,
6
5
  track,
7
6
  trackProductClicked,
8
7
  trackProductListViewed,
9
8
  trackSearchSubmitted,
9
+ wireIdOf,
10
10
  } from "@shop-on/theme-react/analytics";
11
11
 
12
12
  // The view-side of storefront analytics: hooks a section calls to report what
@@ -22,16 +22,16 @@ import {
22
22
  // await `trackCheckoutStarted` before the checkout redirect — all four are in
23
23
  // `@shop-on/theme-react/analytics`.
24
24
 
25
- /** `product_viewed` — once per PDP page load. The numeric id is the join key
25
+ /** `product_viewed` — once per PDP page load. The product's id is the join key
26
26
  * the recommendation trainer and the popularity fallback both use, so a
27
- * product whose id won't parse is skipped rather than logged malformed. */
27
+ * value that is not a product's id is skipped rather than logged malformed. */
28
28
  export function useProductViewed(
29
- productId: string | number | null | undefined,
29
+ productId: string | null | undefined,
30
30
  productHandle: string | undefined,
31
31
  ): void {
32
32
  useEffect(() => {
33
33
  if (!productHandle) return;
34
- const id = toInt(productId);
34
+ const id = wireIdOf(productId, "prod");
35
35
  if (id === null) return;
36
36
  ensureVisit();
37
37
  void track("product_viewed", { product_id: id, product_handle: productHandle });
@@ -40,12 +40,12 @@ export function useProductViewed(
40
40
 
41
41
  /** `collection_viewed` — once per collection PLP page load. */
42
42
  export function useCollectionViewed(
43
- collectionId: string | number | null | undefined,
43
+ collectionId: string | null | undefined,
44
44
  collectionHandle: string | undefined,
45
45
  ): void {
46
46
  useEffect(() => {
47
47
  if (!collectionHandle) return;
48
- const id = toInt(collectionId);
48
+ const id = wireIdOf(collectionId, "collection");
49
49
  if (id === null) return;
50
50
  ensureVisit();
51
51
  void track("collection_viewed", { collection_id: id, collection_handle: collectionHandle });
@@ -63,7 +63,7 @@ export function useSearchSubmitted(query: string, totalCount: number): void {
63
63
  }, [query, totalCount]);
64
64
  }
65
65
 
66
- type ListProduct = { id?: string | number | null; handle?: string };
66
+ type ListProduct = { id?: string | null; handle?: string };
67
67
 
68
68
  /** Impression + click tracking for a product list. Spread the returned
69
69
  * `{ ref, onClickCapture }` onto the grid container and annotate each card
@@ -87,7 +87,7 @@ export function useProductListTracking({
87
87
  products,
88
88
  }: {
89
89
  listType: ProductListType;
90
- listId?: string | number | null;
90
+ listId?: string | null;
91
91
  listHandle?: string;
92
92
  totalCount?: number;
93
93
  products: ReadonlyArray<ListProduct>;
@@ -103,8 +103,8 @@ export function useProductListTracking({
103
103
  // without being torn down and rebuilt on every render; only a signature
104
104
  // change re-creates it.
105
105
  const payloadRef = useRef<{
106
- items: { productId: string | number | null | undefined; position: number }[];
107
- listId?: string | number | null;
106
+ items: { productId: string | null | undefined; position: number }[];
107
+ listId?: string | null;
108
108
  listHandle?: string;
109
109
  totalCount?: number;
110
110
  }>({ items: [] });
@@ -7,6 +7,10 @@
7
7
  "empty": "Your cart is empty.",
8
8
  "heading": "Your cart"
9
9
  },
10
+ "custom_section": {
11
+ "block_error": "Block error",
12
+ "error": "Section error"
13
+ },
10
14
  "footer": {
11
15
  "platform_name": "Cody",
12
16
  "powered_by": "Powered by"
@@ -26,7 +26,11 @@
26
26
  "main_article": "Article",
27
27
  "main_search": "Search results",
28
28
  "main_policy": "Policy",
29
- "main_password": "Password"
29
+ "main_password": "Password",
30
+ "custom_section": "AI-built section"
31
+ },
32
+ "blocks": {
33
+ "custom_block": "AI-built block"
30
34
  },
31
35
  "names": {
32
36
  "custom_css": "Custom CSS"
@@ -42,7 +46,17 @@
42
46
  "cta_label": "Button label",
43
47
  "cta_url": "Button link",
44
48
  "heading": "Heading",
45
- "message": "Message"
49
+ "message": "Message",
50
+ "content_width": "Content width",
51
+ "padding_top": "Top padding",
52
+ "padding_bottom": "Bottom padding"
53
+ },
54
+ "content_width_options": {
55
+ "small": "Narrow",
56
+ "medium": "Medium",
57
+ "large": "Wide",
58
+ "page": "Page width",
59
+ "full": "Full width"
46
60
  },
47
61
  "info": {
48
62
  "custom_css": "Applies to every page. Target a section with its `.section-<type>` class, a block with `.block-<type>`."
@@ -7,6 +7,10 @@
7
7
  "empty": "Таны сагс хоосон байна.",
8
8
  "heading": "Таны сагс"
9
9
  },
10
+ "custom_section": {
11
+ "block_error": "Блокийн алдаа",
12
+ "error": "Хэсгийн алдаа"
13
+ },
10
14
  "footer": {
11
15
  "platform_name": "Cody",
12
16
  "powered_by": "Powered by"
@@ -26,7 +26,11 @@
26
26
  "main_article": "Нийтлэл",
27
27
  "main_search": "Хайлтын үр дүн",
28
28
  "main_policy": "Бодлого",
29
- "main_password": "Нууц үг"
29
+ "main_password": "Нууц үг",
30
+ "custom_section": "AI бүтээсэн хэсэг"
31
+ },
32
+ "blocks": {
33
+ "custom_block": "AI бүтээсэн блок"
30
34
  },
31
35
  "names": {
32
36
  "custom_css": "Өөрийн CSS"
@@ -42,7 +46,17 @@
42
46
  "cta_label": "Товчны бичиг",
43
47
  "cta_url": "Товчны холбоос",
44
48
  "heading": "Гарчиг",
45
- "message": "Мессеж"
49
+ "message": "Мессеж",
50
+ "content_width": "Агуулгын өргөн",
51
+ "padding_top": "Дээд зай",
52
+ "padding_bottom": "Доод зай"
53
+ },
54
+ "content_width_options": {
55
+ "small": "Нарийн",
56
+ "medium": "Дунд",
57
+ "large": "Өргөн",
58
+ "page": "Хуудасны өргөн",
59
+ "full": "Бүтэн өргөн"
46
60
  },
47
61
  "info": {
48
62
  "custom_css": "Бүх хуудсанд үйлчилнэ. Хэсгийг `.section-<type>`, блокийг `.block-<type>` классаар онилно."
@@ -19,7 +19,6 @@ import {
19
19
  } from "@/src/lib/listing-search";
20
20
  import { isPreviewSearch, paginatedPath, templateSeoHead } from "@/src/lib/seo-head";
21
21
  import { getAccountRedirectUrlFn } from "@/src/server/customer";
22
- import { startCheckoutFn } from "@/src/server/checkout-redirect";
23
22
  import {
24
23
  getArticleTemplateFn,
25
24
  getBlogPageTemplateFn,
@@ -71,7 +70,6 @@ export const routeAdapter: ThemeRouteAdapter = {
71
70
  parseBlogSearch,
72
71
  },
73
72
  account: { getAccountRedirectUrlFn },
74
- checkout: { startCheckoutFn },
75
73
  // Add a `Wrapper` here if sections need to know they're in a picker preview.
76
74
  preview: { Unavailable: PreviewUnavailable },
77
75
  };
@@ -29,6 +29,7 @@ import { Route as Char123LocaleChar125AccountVerifyRouteImport } from './routes/
29
29
  import { Route as Char123LocaleChar125BlogsBlogHandleRouteImport } from './routes/{-$locale}/blogs/$blogHandle'
30
30
  import { Route as Char123LocaleChar125CollectionsIndexRouteImport } from './routes/{-$locale}/collections/index'
31
31
  import { Route as Char123LocaleChar125CollectionsCollectionHandleRouteImport } from './routes/{-$locale}/collections/$collectionHandle'
32
+ import { Route as Char123LocaleChar125OrdersFindRouteImport } from './routes/{-$locale}/orders/find'
32
33
  import { Route as Char123LocaleChar125PagesHandleRouteImport } from './routes/{-$locale}/pages/$handle'
33
34
  import { Route as Char123LocaleChar125PoliciesHandleRouteImport } from './routes/{-$locale}/policies/$handle'
34
35
  import { Route as Char123LocaleChar125PreviewSectionRouteImport } from './routes/{-$locale}/preview/section'
@@ -148,6 +149,12 @@ const Char123LocaleChar125CollectionsCollectionHandleRoute =
148
149
  path: '/collections/$collectionHandle',
149
150
  getParentRoute: () => Char123LocaleChar125Route,
150
151
  } as any)
152
+ const Char123LocaleChar125OrdersFindRoute =
153
+ Char123LocaleChar125OrdersFindRouteImport.update({
154
+ id: '/orders/find',
155
+ path: '/orders/find',
156
+ getParentRoute: () => Char123LocaleChar125Route,
157
+ } as any)
151
158
  const Char123LocaleChar125PagesHandleRoute =
152
159
  Char123LocaleChar125PagesHandleRouteImport.update({
153
160
  id: '/pages/$handle',
@@ -206,6 +213,7 @@ export interface FileRoutesByFullPath {
206
213
  '/{-$locale}/account/verify': typeof Char123LocaleChar125AccountVerifyRoute
207
214
  '/{-$locale}/blogs/$blogHandle': typeof Char123LocaleChar125BlogsBlogHandleRoute
208
215
  '/{-$locale}/collections/$collectionHandle': typeof Char123LocaleChar125CollectionsCollectionHandleRoute
216
+ '/{-$locale}/orders/find': typeof Char123LocaleChar125OrdersFindRoute
209
217
  '/{-$locale}/pages/$handle': typeof Char123LocaleChar125PagesHandleRoute
210
218
  '/{-$locale}/policies/$handle': typeof Char123LocaleChar125PoliciesHandleRoute
211
219
  '/{-$locale}/preview/section': typeof Char123LocaleChar125PreviewSectionRoute
@@ -233,6 +241,7 @@ export interface FileRoutesByTo {
233
241
  '/{-$locale}/account/verify': typeof Char123LocaleChar125AccountVerifyRoute
234
242
  '/{-$locale}/blogs/$blogHandle': typeof Char123LocaleChar125BlogsBlogHandleRoute
235
243
  '/{-$locale}/collections/$collectionHandle': typeof Char123LocaleChar125CollectionsCollectionHandleRoute
244
+ '/{-$locale}/orders/find': typeof Char123LocaleChar125OrdersFindRoute
236
245
  '/{-$locale}/pages/$handle': typeof Char123LocaleChar125PagesHandleRoute
237
246
  '/{-$locale}/policies/$handle': typeof Char123LocaleChar125PoliciesHandleRoute
238
247
  '/{-$locale}/preview/section': typeof Char123LocaleChar125PreviewSectionRoute
@@ -262,6 +271,7 @@ export interface FileRoutesById {
262
271
  '/{-$locale}/account/verify': typeof Char123LocaleChar125AccountVerifyRoute
263
272
  '/{-$locale}/blogs/$blogHandle': typeof Char123LocaleChar125BlogsBlogHandleRoute
264
273
  '/{-$locale}/collections/$collectionHandle': typeof Char123LocaleChar125CollectionsCollectionHandleRoute
274
+ '/{-$locale}/orders/find': typeof Char123LocaleChar125OrdersFindRoute
265
275
  '/{-$locale}/pages/$handle': typeof Char123LocaleChar125PagesHandleRoute
266
276
  '/{-$locale}/policies/$handle': typeof Char123LocaleChar125PoliciesHandleRoute
267
277
  '/{-$locale}/preview/section': typeof Char123LocaleChar125PreviewSectionRoute
@@ -292,6 +302,7 @@ export interface FileRouteTypes {
292
302
  | '/{-$locale}/account/verify'
293
303
  | '/{-$locale}/blogs/$blogHandle'
294
304
  | '/{-$locale}/collections/$collectionHandle'
305
+ | '/{-$locale}/orders/find'
295
306
  | '/{-$locale}/pages/$handle'
296
307
  | '/{-$locale}/policies/$handle'
297
308
  | '/{-$locale}/preview/section'
@@ -319,6 +330,7 @@ export interface FileRouteTypes {
319
330
  | '/{-$locale}/account/verify'
320
331
  | '/{-$locale}/blogs/$blogHandle'
321
332
  | '/{-$locale}/collections/$collectionHandle'
333
+ | '/{-$locale}/orders/find'
322
334
  | '/{-$locale}/pages/$handle'
323
335
  | '/{-$locale}/policies/$handle'
324
336
  | '/{-$locale}/preview/section'
@@ -347,6 +359,7 @@ export interface FileRouteTypes {
347
359
  | '/{-$locale}/account/verify'
348
360
  | '/{-$locale}/blogs/$blogHandle'
349
361
  | '/{-$locale}/collections/$collectionHandle'
362
+ | '/{-$locale}/orders/find'
350
363
  | '/{-$locale}/pages/$handle'
351
364
  | '/{-$locale}/policies/$handle'
352
365
  | '/{-$locale}/preview/section'
@@ -509,6 +522,13 @@ declare module '@tanstack/react-router' {
509
522
  preLoaderRoute: typeof Char123LocaleChar125CollectionsCollectionHandleRouteImport
510
523
  parentRoute: typeof Char123LocaleChar125Route
511
524
  }
525
+ '/{-$locale}/orders/find': {
526
+ id: '/{-$locale}/orders/find'
527
+ path: '/orders/find'
528
+ fullPath: '/{-$locale}/orders/find'
529
+ preLoaderRoute: typeof Char123LocaleChar125OrdersFindRouteImport
530
+ parentRoute: typeof Char123LocaleChar125Route
531
+ }
512
532
  '/{-$locale}/pages/$handle': {
513
533
  id: '/{-$locale}/pages/$handle'
514
534
  path: '/pages/$handle'
@@ -566,6 +586,7 @@ interface Char123LocaleChar125RouteChildren {
566
586
  Char123LocaleChar125AccountVerifyRoute: typeof Char123LocaleChar125AccountVerifyRoute
567
587
  Char123LocaleChar125BlogsBlogHandleRoute: typeof Char123LocaleChar125BlogsBlogHandleRoute
568
588
  Char123LocaleChar125CollectionsCollectionHandleRoute: typeof Char123LocaleChar125CollectionsCollectionHandleRoute
589
+ Char123LocaleChar125OrdersFindRoute: typeof Char123LocaleChar125OrdersFindRoute
569
590
  Char123LocaleChar125PagesHandleRoute: typeof Char123LocaleChar125PagesHandleRoute
570
591
  Char123LocaleChar125PoliciesHandleRoute: typeof Char123LocaleChar125PoliciesHandleRoute
571
592
  Char123LocaleChar125PreviewSectionRoute: typeof Char123LocaleChar125PreviewSectionRoute
@@ -592,6 +613,7 @@ const Char123LocaleChar125RouteChildren: Char123LocaleChar125RouteChildren = {
592
613
  Char123LocaleChar125BlogsBlogHandleRoute,
593
614
  Char123LocaleChar125CollectionsCollectionHandleRoute:
594
615
  Char123LocaleChar125CollectionsCollectionHandleRoute,
616
+ Char123LocaleChar125OrdersFindRoute: Char123LocaleChar125OrdersFindRoute,
595
617
  Char123LocaleChar125PagesHandleRoute: Char123LocaleChar125PagesHandleRoute,
596
618
  Char123LocaleChar125PoliciesHandleRoute:
597
619
  Char123LocaleChar125PoliciesHandleRoute,
@@ -141,7 +141,7 @@ function RootComponent() {
141
141
  const { preview } = Route.useSearch();
142
142
  const { shop, i18nMessages, settings } = Route.useLoaderData();
143
143
 
144
- // The shop's PUBLISHED locales, primary first — `ShopType#locales` composes
144
+ // The shop's PUBLISHED locales, primary first — `fetchShopInfo` composes
145
145
  // it that way, and it is the same list the router's locale prefixes are
146
146
  // built from (the i18n snapshot below).
147
147
  const localeCluster = (shop?.locales ?? []).map((l: { locale: string }) => l.locale);
@@ -217,7 +217,7 @@ function RootComponent() {
217
217
  {/* The shop's locale config, inlined into <head> so the client-side
218
218
  i18n snapshot exists before hydration (the router rewrite and
219
219
  getCurrentLocale read it synchronously). `shop.locales` arrives
220
- primary-first and published-only from the storefront scope. */}
220
+ primary-first and published-only from `fetchShopInfo`. */}
221
221
  {shop && localeCluster.length > 0 && (
222
222
  <script
223
223
  dangerouslySetInnerHTML={{
@@ -4,9 +4,9 @@
4
4
  //
5
5
  // Deliberately component-less. `server.handlers` short-circuits before
6
6
  // `executeRouter`, so the root `beforeLoad` password gate never runs here —
7
- // which is exactly right: a locked shop must still answer crawlers, and Rails is
8
- // what decides the body is `Disallow: /`. Adding a `component` would silently
9
- // start 302-ing this route to `/password`.
7
+ // which is exactly right: a locked shop must still answer crawlers, and the
8
+ // api's `locked` is what makes the body `Disallow: /`. Adding a `component`
9
+ // would silently start 302-ing this route to `/password`.
10
10
  //
11
11
  // `server: { handlers: … }` is spelled out here rather than handed back by a
12
12
  // factory: `@tanstack/start-plugin-core` deletes the `server` key from the
@@ -16,12 +16,12 @@
16
16
  // BODY is what's shared, from `@shop-on/theme-routes`.
17
17
  import { createFileRoute } from "@tanstack/react-router";
18
18
  import { robotsHandler } from "@shop-on/theme-routes";
19
- import { getSeoDocument } from "@shop-on/theme-server/seo-proxy";
19
+ import { seoDocuments } from "@shop-on/theme-server/seo-documents";
20
20
 
21
21
  export const Route = createFileRoute("/robots.txt")({
22
22
  server: {
23
23
  handlers: {
24
- GET: robotsHandler({ getSeoDocument }),
24
+ GET: robotsHandler(seoDocuments),
25
25
  },
26
26
  },
27
27
  });
@@ -1,5 +1,6 @@
1
- // `/sitemap.xml` — the index and every chunk off `?kind=&page=`, proxied from
2
- // Rails. Component-less for the same reason as `robots[.]txt.tsx`.
1
+ // `/sitemap.xml` — the index and every file off `?kind=&page=`, written by
2
+ // theme-server from the api's facts. Component-less for the same reason as
3
+ // `robots[.]txt.tsx`.
3
4
  //
4
5
  // `server: { handlers: … }` is spelled out here rather than handed back by a
5
6
  // factory: `@tanstack/start-plugin-core` deletes the `server` key from the
@@ -9,12 +10,12 @@
9
10
  // BODY is what's shared, from `@shop-on/theme-routes`.
10
11
  import { createFileRoute } from "@tanstack/react-router";
11
12
  import { sitemapHandler } from "@shop-on/theme-routes";
12
- import { getSeoDocument } from "@shop-on/theme-server/seo-proxy";
13
+ import { seoDocuments } from "@shop-on/theme-server/seo-documents";
13
14
 
14
15
  export const Route = createFileRoute("/sitemap.xml")({
15
16
  server: {
16
17
  handlers: {
17
- GET: sitemapHandler({ getSeoDocument }),
18
+ GET: sitemapHandler(seoDocuments),
18
19
  },
19
20
  },
20
21
  });
@@ -1,12 +1,17 @@
1
1
  import { createFileRoute } from "@tanstack/react-router";
2
- import { checkoutRouteOptions } from "@shop-on/theme-routes";
3
- import { routeAdapter } from "@/src/route-adapter";
4
-
5
- // The cart → checkout bounce, via checkout's `/begin` on the first visit. See
6
- // docs/theme-cart.md#checkout-handoff.
7
- const { validateSearch, beforeLoad } = checkoutRouteOptions(routeAdapter.checkout);
8
2
 
3
+ // The cart → checkout hand-off (docs/account-checkout-handoff.md): a server
4
+ // route, so its answer can be the form that POSTs the checkout token to the
5
+ // checkout app, never a URL holding it. The node-only body is
6
+ // `@shop-on/theme-server/checkout`, imported inside the handler. `server` is an
7
+ // object literal so the client build drops it (see `customer_logout.tsx`).
9
8
  export const Route = createFileRoute("/{-$locale}/checkout")({
10
- validateSearch,
11
- beforeLoad,
9
+ server: {
10
+ handlers: {
11
+ GET: async ({ request, params }) => {
12
+ const { handleCheckoutGet } = await import("@shop-on/theme-server/checkout");
13
+ return handleCheckoutGet(request, { locale: params.locale });
14
+ },
15
+ },
16
+ },
12
17
  });
@@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
2
2
  import { collectionsIndexRouteOptions, templatePageComponent } from "@shop-on/theme-routes";
3
3
  import { routeAdapter } from "@/src/route-adapter";
4
4
 
5
- // Collections list. `?after=` is an opaque cursor loader dep.
5
+ // Collections list. `?page=` is a loader dep.
6
6
  const { staticData, loaderDeps, loader, head } = collectionsIndexRouteOptions(routeAdapter);
7
7
  const component = templatePageComponent(routeAdapter);
8
8
 
@@ -0,0 +1,13 @@
1
+ import { createFileRoute } from "@tanstack/react-router";
2
+ import { orderLookupRouteOptions } from "@shop-on/theme-routes";
3
+ import { routeAdapter } from "@/src/route-adapter";
4
+
5
+ // The address a merchant links for "Find an order": the account app holds the
6
+ // lookup, so this path on the storefront host only bounces there. Thrown from
7
+ // `beforeLoad`, like the account bounces, so the root loader never runs.
8
+ const { validateSearch, beforeLoad } = orderLookupRouteOptions(routeAdapter.account);
9
+
10
+ export const Route = createFileRoute("/{-$locale}/orders/find")({
11
+ validateSearch,
12
+ beforeLoad,
13
+ });
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "t:sections.custom_section",
3
+ "tag": "section",
4
+ "settings": [
5
+ {
6
+ "type": "select",
7
+ "id": "container",
8
+ "label": "t:settings.content_width",
9
+ "options": [
10
+ { "value": "small", "label": "t:content_width_options.small" },
11
+ { "value": "medium", "label": "t:content_width_options.medium" },
12
+ { "value": "large", "label": "t:content_width_options.large" },
13
+ { "value": "page", "label": "t:content_width_options.page" },
14
+ { "value": "full", "label": "t:content_width_options.full" }
15
+ ],
16
+ "default": "page"
17
+ },
18
+ {
19
+ "type": "range",
20
+ "id": "padding_top",
21
+ "label": "t:settings.padding_top",
22
+ "min": 0,
23
+ "max": 100,
24
+ "step": 4,
25
+ "unit": "px",
26
+ "default": 0
27
+ },
28
+ {
29
+ "type": "range",
30
+ "id": "padding_bottom",
31
+ "label": "t:settings.padding_bottom",
32
+ "min": 0,
33
+ "max": 100,
34
+ "step": 4,
35
+ "unit": "px",
36
+ "default": 0
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,14 @@
1
+ import { BASE_SETTING_IDS } from "@shop-on/theme-contract/custom-section";
2
+ import { expect, it } from "vitest";
3
+ import schema from "./custom-section.json";
4
+
5
+ // A custom section's template reads the contract's base settings
6
+ // (`settings.container`, …) beside its own declared ones, whose ids may not
7
+ // reuse a base id. A setting here outside the contract would let a template
8
+ // read a value the contract doesn't know about. `color_scheme` is the one base
9
+ // id left out: the theme has no color schemes yet, so its picker would do
10
+ // nothing. Declare it when the schemes arrive.
11
+ it("declares the contract's base settings, but color_scheme", () => {
12
+ const ids = schema.settings.flatMap((s) => ("id" in s ? [s.id] : []));
13
+ expect(ids.toSorted()).toEqual(BASE_SETTING_IDS.filter((id) => id !== "color_scheme").toSorted());
14
+ });
@@ -0,0 +1,73 @@
1
+ import type { CSSProperties } from "react";
2
+ import { useTranslations } from "@shop-on/i18n";
3
+ import { CustomSectionHtml } from "@shop-on/theme-react/custom-section-html";
4
+
5
+ // `page` is the theme container and `full` is edge to edge; the rest cap the
6
+ // content's measure inside the container.
7
+ const WIDTHS: Record<string, string> = {
8
+ small: "44rem",
9
+ medium: "60rem",
10
+ large: "78rem",
11
+ };
12
+
13
+ // A section an AI assistant wrote: Liquid the custom-section pass
14
+ // (`renderCustomSections`, @shop-on/theme-loader/custom-sections, called from
15
+ // `loadTemplate` in src/server/settings.ts) validated and rendered on the
16
+ // server, arriving here as a finished HTML string on `customHtml`. The
17
+ // instance's `definition` (its template and declared settings) never reaches
18
+ // this component: the pass deletes it.
19
+ //
20
+ // Rendered through the shared `CustomSectionHtml`, never a raw
21
+ // `dangerouslySetInnerHTML` or a Custom HTML snippet that re-activates
22
+ // `<script>` tags: model-written markup must not run one. `CustomSectionHtml`
23
+ // also hands clicks on its internal links to the router.
24
+ export default function CustomSection({
25
+ sectionId,
26
+ customHtml = null,
27
+ customError = null,
28
+ container = "page",
29
+ padding_top = 0,
30
+ padding_bottom = 0,
31
+ }: {
32
+ sectionId?: string;
33
+ customHtml?: string | null;
34
+ customError?: string | null;
35
+ container?: string | null;
36
+ padding_top?: number | null;
37
+ padding_bottom?: number | null;
38
+ }) {
39
+ const t = useTranslations("custom_section");
40
+
41
+ // Nothing rendered, nothing shown. An error shows only in the editor: the
42
+ // pass writes `customError` only when the request carries an editor `sid`.
43
+ if (!customError && !customHtml?.trim()) return null;
44
+
45
+ const measure = WIDTHS[container ?? "page"];
46
+ const body = customError ? (
47
+ <p className="rounded-lg border border-border p-4 text-sm text-muted">
48
+ {t("error")}: {customError}
49
+ </p>
50
+ ) : (
51
+ <CustomSectionHtml html={customHtml ?? ""} />
52
+ );
53
+
54
+ return (
55
+ <section
56
+ data-section-id={sectionId}
57
+ style={{ paddingTop: `${padding_top ?? 0}px`, paddingBottom: `${padding_bottom ?? 0}px` }}
58
+ >
59
+ <div className={container === "full" ? undefined : "mx-auto max-w-6xl px-6"}>
60
+ {measure ? (
61
+ <div
62
+ className="mx-auto w-full max-w-(--cs-w)"
63
+ style={{ "--cs-w": measure } as CSSProperties}
64
+ >
65
+ {body}
66
+ </div>
67
+ ) : (
68
+ body
69
+ )}
70
+ </div>
71
+ </section>
72
+ );
73
+ }
@@ -21,7 +21,12 @@
21
21
  "default": "t:text_defaults.hero_body"
22
22
  },
23
23
  { "type": "text", "id": "cta_label", "label": "t:settings.cta_label" },
24
- { "type": "url", "id": "cta_url", "label": "t:settings.cta_url" }
24
+ {
25
+ "type": "url",
26
+ "id": "cta_url",
27
+ "label": "t:settings.cta_url",
28
+ "visible_if": "{{ section.settings.cta_label != blank }}"
29
+ }
25
30
  ],
26
31
  "presets": [{ "name": "t:sections.hero" }]
27
32
  }