create-magic-storefront 0.1.3 → 0.2.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/README.md +6 -0
- package/dist/index.js +40 -3
- package/package.json +1 -1
- package/template/.claude/skills/storefront-design/SKILL.md +19 -18
- package/template/.claude/skills/storefront-verify/SKILL.md +10 -9
- package/template/AGENTS.md +4 -1
- package/template/PAGES.md +48 -11
- package/template/app/blog/[handle]/page.tsx +136 -0
- package/template/app/blog/author/[handle]/page.tsx +44 -0
- package/template/app/blog/category/[handle]/page.tsx +52 -0
- package/template/app/blog/page.tsx +97 -0
- package/template/app/blog/tag/[handle]/page.tsx +51 -0
- package/template/app/globals.css +68 -0
- package/template/app/layout.tsx +2 -0
- package/template/app/sitemap.ts +16 -6
- package/template/components/analytics-views.tsx +7 -0
- package/template/components/article-body.tsx +58 -0
- package/template/components/article-card.tsx +54 -0
- package/template/components/article-vote.tsx +43 -0
- package/template/components/blog-listing.tsx +93 -0
- package/template/components/pager.tsx +8 -2
- package/template/components/product-grid.tsx +27 -20
- package/template/lib/errors.ts +2 -1
- package/template/lib/i18n.ts +46 -0
- package/template/lib/site.ts +12 -0
- package/template/llms.txt +30 -6
package/template/llms.txt
CHANGED
|
@@ -11,12 +11,15 @@ Every storefront — hand-written or generated — imports the SDK **only** thro
|
|
|
11
11
|
| ------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------- |
|
|
12
12
|
| `@magicstoreai/storefront-client` | `createStorefrontClient`: one typed method per API `operationId`, `MagicStoreError`, `paginate`, `Schema<>` | anywhere, no React |
|
|
13
13
|
| `@magicstoreai/hydrogen` | React: `MagicStoreProvider`, `useCart`, `useCustomer`, `useWishlist`, `<Money>`, `<Image>`, … | client (`"use client"`) |
|
|
14
|
-
| `@magicstoreai/hydrogen/core` | The same state without React: `CartController`, `CustomerSessionController`, `formatMoney`, variants
|
|
14
|
+
| `@magicstoreai/hydrogen/core` | The same state without React: `CartController`, `CustomerSessionController`, `formatMoney`, variants, blog | anywhere |
|
|
15
15
|
| `@magicstoreai/hydrogen/server` | `nextCacheFetch` (cache tags), `createWebhookHandler` (signed webhooks → revalidation) | server, edge |
|
|
16
|
-
| `@magicstoreai/hydrogen/seo` | `pageMeta`, `productJsonLd`, `breadcrumbJsonLd`, `jsonLdScript`
|
|
16
|
+
| `@magicstoreai/hydrogen/seo` | `pageMeta`, `productJsonLd`, `articleMeta`, `articleJsonLd`, `breadcrumbJsonLd`, `jsonLdScript` | anywhere |
|
|
17
17
|
|
|
18
18
|
Never import from `src/` or `dist/` of a package, and never call `/api/v2/storefront/…` by URL —
|
|
19
|
-
call the client method.
|
|
19
|
+
call the client method. A server component takes only components (`<Image>`, `<Money>`, …) from
|
|
20
|
+
`@magicstoreai/hydrogen`, a client module; functions and classes (`paginationState`,
|
|
21
|
+
`MagicStoreError`, `formatMoney`) come from `/core`, `/server`, `/seo` or
|
|
22
|
+
`@magicstoreai/storefront-client`. `npx create-magic-storefront check` fails on any of these.
|
|
20
23
|
|
|
21
24
|
## Start
|
|
22
25
|
|
|
@@ -25,14 +28,14 @@ npm create magic-storefront@latest my-shop -- --shop shop.example.uz
|
|
|
25
28
|
```
|
|
26
29
|
|
|
27
30
|
scaffolds a Next.js App Router storefront (home from the merchant's sections or your own, catalog,
|
|
28
|
-
product, search, cart, checkout, sign-in, orders, SEO, webhook revalidation). Or install the packages:
|
|
31
|
+
product, search, blog, cart, checkout, sign-in, orders, SEO, webhook revalidation). Or install the packages:
|
|
29
32
|
`npm i @magicstoreai/storefront-client @magicstoreai/hydrogen`.
|
|
30
33
|
|
|
31
34
|
## Docs
|
|
32
35
|
|
|
33
36
|
- `PAGES.md` (in a scaffolded storefront; `examples/starter/PAGES.md` in the SDK repository): how to
|
|
34
37
|
build each page type — home (from the `/home` sections or custom), collection, product, search,
|
|
35
|
-
cart, checkout, account — with its data calls, cache tags, SEO and required states.
|
|
38
|
+
blog, cart, checkout, account — with its data calls, cache tags, SEO and required states.
|
|
36
39
|
- [Hydrogen catalogue](node_modules/@magicstoreai/hydrogen/CATALOGUE.md): every export with its props
|
|
37
40
|
or signature, an example, and the API operations it calls. In the SDK repository:
|
|
38
41
|
`packages/hydrogen/CATALOGUE.md`.
|
|
@@ -40,7 +43,8 @@ product, search, cart, checkout, sign-in, orders, SEO, webhook revalidation). Or
|
|
|
40
43
|
idempotency, retries, errors, pagination.
|
|
41
44
|
- [Hydrogen README](node_modules/@magicstoreai/hydrogen/README.md): provider, hooks, server helpers.
|
|
42
45
|
- The API itself (normative): the backend repository's `docs/api/v2/` — `standards.md` (wire format,
|
|
43
|
-
every error code), `authentication.md`, `cart.md`, `checkout.md`, `customer.md`, `
|
|
46
|
+
every error code), `authentication.md`, `cart.md`, `checkout.md`, `customer.md`, `blog.md`,
|
|
47
|
+
`webhooks.md`.
|
|
44
48
|
Operation shapes: `Schema<'Name'>` and the client's method types, generated from the OpenAPI spec.
|
|
45
49
|
|
|
46
50
|
## Two credentials
|
|
@@ -70,6 +74,26 @@ Public catalog reads need no customer. Render them on the server with a client w
|
|
|
70
74
|
merchant arrange the page from the admin, or compose a custom home from catalog and content
|
|
71
75
|
data. When you render it, an unknown type renders as nothing.
|
|
72
76
|
|
|
77
|
+
## Blog
|
|
78
|
+
|
|
79
|
+
- Only when `shop.features.blog` is on: at least one article is readable in the response language.
|
|
80
|
+
`shop.blog` is the blog home's `{ title, description }` or `null`.
|
|
81
|
+
- `blogArticlesIndex` (12 a page; `sort`, `q`, `filter[category|author|tag|featured]`),
|
|
82
|
+
`blogArticlesShow`, `blogArticlesRelated`, `blogCategoriesIndex`, `blogAuthorsIndex`. An unknown
|
|
83
|
+
`sort` or filter is `422 VALIDATION_FAILED`, never ignored.
|
|
84
|
+
- Articles are strict about language: one not written in the response locale is a `404`, with no
|
|
85
|
+
fallback. Build `hreflang` only from `availableLocales` (`articleMeta` does).
|
|
86
|
+
- `bodyHtml` is sanitized by the server. Split it with `articleBodyBlocks()` (`/core`, server-safe):
|
|
87
|
+
`<product-embed handle>` → a product card, `<oembed url>` → media, `<aside data-callout>` → a
|
|
88
|
+
callout. Fetch the embedded products in one `productsIndex({ query: { 'filter[handles]' } })` per
|
|
89
|
+
`embeddedProductFilters(article.products)` value, put them back in order with
|
|
90
|
+
`orderEmbeddedProducts`, and drop a marker whose product did not come back.
|
|
91
|
+
- «Was this helpful?»: `useArticleVote(handle, helpfulCount)`. A guest votes as the browser
|
|
92
|
+
(`X-Anonymous-Id`, `anonymousId()`), a customer as themselves. Report reads with
|
|
93
|
+
`useAnalytics().articleView(article.id)` (`ARTICLE_VIEW`).
|
|
94
|
+
- Blog reads are cached under `magicstore:pages` (`PAGES_UPDATED`); view and vote counters may be
|
|
95
|
+
up to 10 minutes old.
|
|
96
|
+
|
|
73
97
|
## Credentials in the browser
|
|
74
98
|
|
|
75
99
|
The cart id and the checkout id are credentials. Never log them and never put them in a URL or
|