@eldrajs/theme-nuxt 0.0.0-stage → 0.1.1
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/CHANGELOG.md +233 -0
- package/LICENSE +21 -0
- package/README.md +324 -2
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +56 -0
- package/dist/module.d.ts +56 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +265 -0
- package/dist/runtime/catalog.d.ts +119 -0
- package/dist/runtime/catalog.js +226 -0
- package/dist/runtime/commerce.d.ts +68 -0
- package/dist/runtime/commerce.js +40 -0
- package/dist/runtime/composables/useEldraPage.d.ts +17 -0
- package/dist/runtime/composables/useEldraPage.js +229 -0
- package/dist/runtime/designTokens.d.ts +59 -0
- package/dist/runtime/designTokens.js +55 -0
- package/dist/runtime/drafts.d.ts +3 -0
- package/dist/runtime/drafts.js +83 -0
- package/dist/runtime/links.d.ts +32 -0
- package/dist/runtime/links.js +132 -0
- package/dist/runtime/locale.d.ts +21 -0
- package/dist/runtime/locale.js +9 -0
- package/dist/runtime/localeState.d.ts +52 -0
- package/dist/runtime/localeState.js +48 -0
- package/dist/runtime/locales.d.ts +186 -0
- package/dist/runtime/locales.js +109 -0
- package/dist/runtime/messages.d.ts +59 -0
- package/dist/runtime/messages.js +66 -0
- package/dist/runtime/origins.d.ts +18 -0
- package/dist/runtime/origins.js +28 -0
- package/dist/runtime/plugin.d.ts +3 -0
- package/dist/runtime/plugin.js +83 -0
- package/dist/runtime/resolveRoute.d.ts +81 -0
- package/dist/runtime/resolveRoute.js +166 -0
- package/dist/runtime/routePath.d.ts +31 -0
- package/dist/runtime/routePath.js +7 -0
- package/dist/runtime/staticRoutes.d.ts +14 -0
- package/dist/runtime/staticRoutes.js +26 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +66 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# @eldrajs/theme-nuxt changelog
|
|
2
|
+
|
|
3
|
+
Hand-maintained: every change a consumer can see gets a line under Unreleased in the same change.
|
|
4
|
+
Release-please writes the generated notes from commit messages and does not replace this.
|
|
5
|
+
|
|
6
|
+
## Unreleased
|
|
7
|
+
|
|
8
|
+
- **The deployed site now carries Studio's design-token overrides, not only the open preview.** A
|
|
9
|
+
fourth fail-soft read, alongside the store's currency, its locales and the theme-message overrides
|
|
10
|
+
— `GET /site/v1/design-tokens`, same client, same retry policy, absent gateway or any error
|
|
11
|
+
answering `null` with one warning (`readDesignTokens`, `./runtime/designTokens.ts`) — answers the
|
|
12
|
+
organisation's resolved catalog (the theme's own tokens with the site's overrides already
|
|
13
|
+
applied, re-validated through `@eldrajs/theme-core`'s `normalizeThemeDesignTokens`). The result is
|
|
14
|
+
what `virtual:eldra/tokens.css` now generates its CSS from — `@eldrajs/vite-plugin-theme`'s
|
|
15
|
+
`eldraTheme()` gained a `resolveTokens` option for exactly this, set once the module's own
|
|
16
|
+
platform read settles — and what the runtime plugin seeds `context.designTokens` from
|
|
17
|
+
(`runtimeConfig.public.eldra.designTokens`, carried the same way `commerce`/`locales` are), so a
|
|
18
|
+
generated static artifact's CSS and its runtime context both reflect the override through SSR,
|
|
19
|
+
prerender and hydration. The preview bridge path (`applyResolvedDesignTokens`) is unchanged.
|
|
20
|
+
|
|
21
|
+
- **The theme's message catalogue is now merged with the platform's overrides at build time.** A
|
|
22
|
+
third fail-soft read, alongside the store's currency and locales — `GET /site/v1/theme-messages`,
|
|
23
|
+
same client, same retry policy, absent gateway or any error answering `null` with one warning
|
|
24
|
+
(`readThemeMessages`, `./runtime/messages.ts`) — is merged over the manifest's own `messages`
|
|
25
|
+
block and resolved over the organisation's locales (falling back to the theme's own locales/
|
|
26
|
+
default locale when those are unknown) via `@eldrajs/theme-core/i18n`'s
|
|
27
|
+
`mergeMessageCatalogues`/`resolveMessageCatalogue`. The result is what `virtual:eldra/messages`
|
|
28
|
+
now serves — `@eldrajs/vite-plugin-theme`'s `eldraTheme()` gained a `resolveMessages` option for
|
|
29
|
+
exactly this, set once the module's own platform read settles — and what the runtime plugin
|
|
30
|
+
assigns to `context.messages`, so the starter's `vue-i18n` plugin (next) reads one source for
|
|
31
|
+
every organisation locale's full key set, gateway or none.
|
|
32
|
+
|
|
33
|
+
- **Fix: a `link` field's mega-menu/footer column heading no longer vanishes on a locale that never
|
|
34
|
+
got its own `group`.** The runtime plugin now resolves the organisation's content locales before
|
|
35
|
+
building the gateway client, and hands it `defaultLocale` (the store's own `locales.default`,
|
|
36
|
+
falling back to the resolved routing default for a single-locale site) — `@eldrajs/theme-core`'s
|
|
37
|
+
per-field link fallback (see its changelog) then fills an untranslated field of a `link` node from
|
|
38
|
+
the default locale's node instead of leaving it empty.
|
|
39
|
+
|
|
40
|
+
- **`eldra.retry` — how hard a build tries again when the gateway says "not now".**
|
|
41
|
+
`{ attempts, baseDelayMs, maxDelayMs }`, defaulting to five attempts with exponential backoff and
|
|
42
|
+
jitter while honouring `Retry-After`; `{ attempts: 0 }` turns it off. It reaches every gateway read
|
|
43
|
+
a site makes: this module's own `prerender:routes` reads and the platform read behind
|
|
44
|
+
`commerce`/`locales`, and the client the runtime plugin builds for the theme. It is also written to
|
|
45
|
+
the public runtime config (`useRuntimeConfig().public.eldra.retry`), so a storefront that builds
|
|
46
|
+
its own `@eldrajs/sdk` client for commerce reads can hand it the same policy. Nothing has to be set
|
|
47
|
+
for the default behaviour, which is what keeps a `nuxi generate` of a large site alive through the
|
|
48
|
+
gateway's per-minute rate limit — see the README's "When the gateway rate-limits the build".
|
|
49
|
+
|
|
50
|
+
- **Category pages.** A route template whose `schemaApiId` is `catalog:category` is now resolved
|
|
51
|
+
against the store's category tree. Its pattern ends in a catch-all parameter and its `slugField`
|
|
52
|
+
is `path` (`/categories/:path*`), and a category is addressed by its **canonical path** — the
|
|
53
|
+
slugs of its ancestors, root first, then its own (`/categories/billinn/bilstolar`). There is no
|
|
54
|
+
read that takes a path, so the whole category list is read and the path's segments are walked down
|
|
55
|
+
the tree by slug; **only the canonical path resolves**, so a leaf on its own, a wrong parent and a
|
|
56
|
+
trailing extra segment are each the not-found shell rather than a redirect. `useEldraPage()`'s
|
|
57
|
+
`catalog` is `{ kind: 'category', slug, path }` there — the leaf's slug and the whole path — and
|
|
58
|
+
the resolved entry carries the binding paths `slug`, `title`, `path`, `ancestors[]` and
|
|
59
|
+
`children[]`, plus `description` (plain text, like a collection's) and `productCount` only when the catalog read
|
|
60
|
+
carried them (the category model may have neither, and an invented key would bind a template to an
|
|
61
|
+
empty value on every site without one).
|
|
62
|
+
- `prerender:routes` adds one route per **canonical** category path, times the site's locales, the
|
|
63
|
+
same way it fans out collections. A category the list cannot place — no slug, or a parent the list
|
|
64
|
+
does not hold — gets no route, and neither does the subtree under it: a path built over that gap
|
|
65
|
+
addresses a different category.
|
|
66
|
+
- A `link` field pointing at a **category** now resolves to the canonical path. The category targets
|
|
67
|
+
are read as one whole tree rather than in `id:in:` chunks, because a chunked read keyed on the
|
|
68
|
+
wanted ids alone discards the ancestors the path is built from; a target the tree cannot place
|
|
69
|
+
carries no path and renders as plain text rather than as a link the site answers with its
|
|
70
|
+
not-found shell. A reader with no `listCategories` resolves none, exactly as before.
|
|
71
|
+
|
|
72
|
+
- **A route the gateway could not be asked about is no longer rendered as the not-found page.**
|
|
73
|
+
`useEldraPage()`'s resolution failure now travels with the resolution itself rather than in the
|
|
74
|
+
calling composable's own `error` ref: `useAsyncData` keeps one entry per route key and runs only
|
|
75
|
+
the **first** caller's handler, so a theme that calls `useEldraPage()` twice on a page (a plugin
|
|
76
|
+
for the catalog route beside the page component — which the starter does) saw the failure in one
|
|
77
|
+
of them and an ordinary empty resolution in the other. That is indistinguishable from "there is
|
|
78
|
+
no such page", so a transient gateway failure drew the theme's not-found shell, and `nuxi
|
|
79
|
+
generate` wrote it to disk under a path a visitor can reach, with exit code 0. On the server such
|
|
80
|
+
a route is now answered `500` as well, so Nitro writes no file for it and names it in the
|
|
81
|
+
prerender list (pair it with `nitro.prerender.failOnError` to stop the build — its real exposure is
|
|
82
|
+
about twice the route count, because each page's `_payload.json` is prerendered too and resolves
|
|
83
|
+
the route again). A build with no `ELDRA_GATEWAY_URL` / `ELDRA_ORG_ID` is exempt from **both** the
|
|
84
|
+
status and the error: there every read fails by definition, so such a route resolves to the plain
|
|
85
|
+
empty route and the theme renders its static shell, exactly as it did before. The resolved route's
|
|
86
|
+
new optional `error` field is set only for a failure — a genuine not-found (no match, or a 404 from
|
|
87
|
+
the gateway) carries none, exactly as before — and `useEldraPage()`'s `error` is now typed
|
|
88
|
+
`ComputedRef<string | null>`, which is what it has always been at runtime.
|
|
89
|
+
|
|
90
|
+
- **Locale-prefixed routing.** `runtimeConfig.public.eldra` now carries `locales` — the
|
|
91
|
+
organisation's own `{ default, supported }` record, read once during the build, or `null` — and
|
|
92
|
+
the module serves the default locale at `/` with every other supported locale under a path
|
|
93
|
+
prefix (`/is-IS/products/ash-glaze-mug`). The first path segment selects the locale, the rest of
|
|
94
|
+
the path resolves as it does unprefixed, and every gateway read for that page carries that
|
|
95
|
+
`locale`; `/<default-locale>/…` is not generated and resolves as an unknown path. Path segments
|
|
96
|
+
are not translated — a page keeps its default-locale slug under every prefix — so the prerender
|
|
97
|
+
pass lists each content path once and writes it once per locale, seeded `cart`/`wishlist`/`search`
|
|
98
|
+
pages included. The key's type ships as `StoreLocales` (`@eldrajs/theme-nuxt/locales`, a new
|
|
99
|
+
subpath export beside `./commerce`), a new auto-imported `useEldraLocale()` answers which locale
|
|
100
|
+
the page is and prefixes a destination for it, and the module writes `<html lang>` plus an
|
|
101
|
+
`hreflang` alternate per locale (and `x-default`) itself. `useEldraLocale().name(locale)` is that
|
|
102
|
+
locale's own name for a switcher's label, resolved **on the server** and carried in the payload —
|
|
103
|
+
`Intl.DisplayNames` is ICU data and a renderer and a browser need not have the same of it, so a
|
|
104
|
+
page that let each side compute its own labels would hydrate into a mismatch and repaint.
|
|
105
|
+
`eldra.locale` / `ELDRA_LOCALE` keeps its meaning as an override of the **default** locale: naming a supported locale moves it to `/`,
|
|
106
|
+
naming anything else changes no URL and is still forwarded on every read. An organisation with no
|
|
107
|
+
locales, a site built without gateway credentials and a failed read all behave exactly as every
|
|
108
|
+
site did before this: one unprefixed site, no switcher — and only the failed read prints a
|
|
109
|
+
warning, because the other two are not mistakes.
|
|
110
|
+
|
|
111
|
+
- `eldra.templates` accepts static **page** seeds beside the route-template seeds it already took —
|
|
112
|
+
`{ page: { slug }, title, blocks }`, where an entry of `blocks` is either a block
|
|
113
|
+
(`{ apiId, data, required? }`) or a placement of the site's shared header or footer
|
|
114
|
+
(`{ role: 'header' | 'footer' }`). See `@eldrajs/vite-plugin-theme`'s changelog for the grammar;
|
|
115
|
+
this module only widens the option's type and forwards it.
|
|
116
|
+
|
|
117
|
+
- `useEldraPage` no longer replaces the page with an error alert for the first 401 of a preview
|
|
118
|
+
read. A preview token is one hash per organization, so minting one anywhere else revokes the one
|
|
119
|
+
a live preview is using; the editor answers `theme:request-failed` by minting again and
|
|
120
|
+
re-sending `editor:init`, usually within a second, and reporting that first failure blanked the
|
|
121
|
+
page for exactly that second — and, because every keystroke re-reads the drafts, produced one
|
|
122
|
+
alert per keystroke with the page gone. The first failure is held back (what is on screen stays,
|
|
123
|
+
rather than collapsing to the not-found shell) and the error is reported once a 401 arrives on a
|
|
124
|
+
*newer* token — the retry failed too — or after a 10s grace window, so a preview nobody is going
|
|
125
|
+
to recover still says so.
|
|
126
|
+
|
|
127
|
+
- `runtimeConfig.public.eldra` now carries `commerce` — `{ currency, taxInclusivePricing,
|
|
128
|
+
defaultTaxRate }`, or `null` — read once from the organisation during the build, so a prerendered
|
|
129
|
+
page's prices are formatted in the currency the store actually sells in instead of one the theme
|
|
130
|
+
guessed from the content locale. The key's type ships with the package as `StoreCommerce`, so a
|
|
131
|
+
theme reading it does not hand-write the record (`@eldrajs/theme-nuxt/commerce`, a new subpath
|
|
132
|
+
export — the package root's declarations are generated by `nuxt-module-build` and carry the module
|
|
133
|
+
and its options only). A store with no commerce settings, a site built
|
|
134
|
+
without gateway credentials and a read that failed all land on `null` with a single warning
|
|
135
|
+
(`[eldra] the store publishes no currency — prices render as plain numbers`, plus the cause in
|
|
136
|
+
brackets when the read itself failed); the build never fails over it. The module adds no
|
|
137
|
+
environment override: the platform is the source, and a theme-side currency could only relabel
|
|
138
|
+
real amounts. See the README for what a theme should do with `null`.
|
|
139
|
+
|
|
140
|
+
- The batched target reads behind a `link` field now page to the end of a result rather than
|
|
141
|
+
stopping at the first hundred rows, and the category read asks for the ids it actually needs
|
|
142
|
+
(`id:in:`, in chunks, like the product and collection reads) and keeps only those. A target lost
|
|
143
|
+
past a page boundary renders as a link with no destination, which is indistinguishable from a
|
|
144
|
+
deleted one; and a category tree read whole would otherwise put every category a site has into
|
|
145
|
+
the prerendered payload of every page that links to one.
|
|
146
|
+
|
|
147
|
+
- The walk that finds which targets a page names reaches far deeper before it gives up, and says so
|
|
148
|
+
when it does — naming the entry — instead of returning silently. The old bound could be reached
|
|
149
|
+
by a link nested inside a composite inside a list, and the only symptom was a link that quietly
|
|
150
|
+
had no destination.
|
|
151
|
+
|
|
152
|
+
- A `link` field's destinations now resolve to real hrefs on a generated site. Route resolution
|
|
153
|
+
fills the theme context's `links` slice from the page and route-template lists it already reads,
|
|
154
|
+
plus one batched read per target type for the objects the resolved document's blocks name — all
|
|
155
|
+
inside the same `useAsyncData` call, so a `nuxi generate` build bakes every href into the page's
|
|
156
|
+
payload and a prerendered page resolves them with no client request. A read that fails leaves
|
|
157
|
+
those targets unknown: the links pointing at them render unlinked rather than failing the page.
|
|
158
|
+
`useEldraPage()` also returns the slice as `links`.
|
|
159
|
+
|
|
160
|
+
- Fix: on a **generated** site in a browser, `useEldraPage()` now resolves routes from the build
|
|
161
|
+
instead of the gateway. A path Nuxt prerendered (its app manifest ships the list) is read back out
|
|
162
|
+
of the route payload Nuxt has already loaded, so a client navigation between two prerendered
|
|
163
|
+
routes renders in the same tick — `pending` never true, no gateway read — and a path the build
|
|
164
|
+
does not contain is the not-found state immediately, instead of after listing every page and every
|
|
165
|
+
route template to reach the same answer. Studio preview (the route may be a draft), `nuxi dev` and
|
|
166
|
+
an SSR deployment all keep the dynamic resolution they had. New pages need a rebuild to become
|
|
167
|
+
routes, which is what publishing already triggers.
|
|
168
|
+
|
|
169
|
+
- Fix: a page component now resolves the route **it** is being created for. `useRoute()` inside a
|
|
170
|
+
package resolves to Nuxt's app-level route, which `NuxtPage` syncs only after the destination
|
|
171
|
+
page's `<Suspense>` has resolved — and a page's blocks are created inside that pending branch. So
|
|
172
|
+
on every client navigation the destination page ran its `setup` under the route it was replacing:
|
|
173
|
+
it rendered the **departing** page's blocks, ran every read on them a second time, and only then
|
|
174
|
+
swapped to its own content. `useEldraPage()` now reads the router's committed route and pins it
|
|
175
|
+
for the page's lifetime (the identity `eldraRouteKey` already gives `<NuxtPage>`); called outside
|
|
176
|
+
a component — for a plugin's route context — it follows the committed route directly.
|
|
177
|
+
|
|
178
|
+
- Fix: a page served at a URL that differs from the one it was prerendered at only by a trailing
|
|
179
|
+
slash is no longer built twice. A generated site is `<route>/index.html`, and a static host may
|
|
180
|
+
answer `/products/ash-glaze-mug` with a redirect to `/products/ash-glaze-mug/`; Nuxt then
|
|
181
|
+
re-navigates between the two paths while the page hydrates, and the catch-all route's default key
|
|
182
|
+
differs between them — so the page, and every block on it, was destroyed and created again,
|
|
183
|
+
running each block's `setup` (and every storefront read in it) a second time. `useEldraPage()` now
|
|
184
|
+
watches the **canonical** path, the one its async-data key already used, and the module
|
|
185
|
+
auto-imports `eldraRouteKey` for a theme to give `<NuxtPage>` (`:page-key="eldraRouteKey"`) so the
|
|
186
|
+
page survives that move. Themes scaffolded before this should add the `page-key` binding; the
|
|
187
|
+
starter does.
|
|
188
|
+
|
|
189
|
+
- Feat: `useEldraPage()` exposes `reusableComponentProjection` on a **route-template** route. Core
|
|
190
|
+
attaches the projection to whichever document the read returned, and a route resolves exactly one
|
|
191
|
+
of the two — a static route a `page`, a dynamic one a `template` — so the composable now reads the
|
|
192
|
+
page's, else the template's. It is a fallback and never a merge: `@eldrajs/theme-core` refuses a
|
|
193
|
+
projection carrying a binding the rendered document does not place, so a page's projection on a
|
|
194
|
+
template route would fail the layout closed. Preview drafts already reach a placement inside a
|
|
195
|
+
template the same way they reach one inside a page; nothing there needed lifting. The public
|
|
196
|
+
route-template read carries no projection — it is pre-expanded and redacted like a public page
|
|
197
|
+
read — so a prerendered template route renders its header and footer with no component or site
|
|
198
|
+
identity anywhere in the HTML or the payload.
|
|
199
|
+
- Fix: a blank locale is no longer forwarded to the gateway. A site that configures none carries
|
|
200
|
+
`""` — that is what `runtimeConfig.public.eldra.locale` holds, and what an unset `ELDRA_LOCALE`
|
|
201
|
+
becomes — which went out as `?locale=` on every read and came back a 400 from the collection
|
|
202
|
+
lookup. Every boundary that forwards a locale (`useEldraPage()`, route resolution, the catalog
|
|
203
|
+
reads, the module's `prerender:routes` pass and the public runtime config it writes) now treats
|
|
204
|
+
a blank or whitespace-only locale as no locale at all, so the request carries no `locale`
|
|
205
|
+
parameter and the gateway serves the site's default. A blank `locale` from the Studio preview
|
|
206
|
+
bridge falls back to the configured one instead of shadowing it.
|
|
207
|
+
|
|
208
|
+
- Removed the unused `catalogTemplateRoutes` helper from the runtime (never exported from the
|
|
209
|
+
module's public entry, and `prerender:routes` cannot use it: it lists the catalog once per
|
|
210
|
+
**kind** and maps once per template, so a list-and-map-in-one call would refetch the whole
|
|
211
|
+
catalog for every template). Compose `listCatalogDocs` + `catalogDocRoutes` instead.
|
|
212
|
+
|
|
213
|
+
- New `eldra.templates` and `eldra.templateRoles` options, forwarded to
|
|
214
|
+
`@eldrajs/vite-plugin-theme`: the default page templates a site is seeded with on its first
|
|
215
|
+
deploy, and the block data behind the `header`/`footer` roles those seeds place. See that
|
|
216
|
+
package's changelog for the seed shape and its validation.
|
|
217
|
+
|
|
218
|
+
- Feat: catalog-backed route templates render. A route template whose `schemaApiId` is
|
|
219
|
+
`catalog:product` or `catalog:collection` now resolves its object **by slug** through the public
|
|
220
|
+
catalog instead of a CMS entry, and `useEldraPage()` returns a new `catalog`
|
|
221
|
+
(`{ kind: 'product' | 'collection'; slug }`, `null` for every other route) beside `page`,
|
|
222
|
+
`template` and `entry`. The bound `entry` is `{ id, data }` where `data` holds the documented
|
|
223
|
+
binding paths — product: `slug`, `title`, `description`, `status`, `categoryId`, `tags`,
|
|
224
|
+
`variants[]` (`sku`, `price`, `compareAtPrice`, `optionValues[]`), `images[]` (`url`, `alt`);
|
|
225
|
+
collection: `slug`, `title`, `description`, `productCount`, `image` (`url`, `alt`) — every key
|
|
226
|
+
always present, whatever the response omitted. A slug the catalog does not know renders the
|
|
227
|
+
theme's not-found shell, not its error branch.
|
|
228
|
+
- Feat: generation prerenders one route per active catalog object, paging the public list endpoints
|
|
229
|
+
at 100 per page (products filtered to `status:eq:ACTIVE` server-side, and any inactive record the
|
|
230
|
+
gateway still reports dropped client-side). A slug that cannot become a route, or one that
|
|
231
|
+
collides with a route already generated, is skipped with an `[eldra] skipped …` warning naming it
|
|
232
|
+
and the build continues — merchant catalog data must not be able to fail a whole deploy.
|
|
233
|
+
- First release under the `@eldrajs` scope, moved from the private `@eldra/theme-nuxt` package.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Eldra Tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,325 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @eldrajs/theme-nuxt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nuxt module for Eldra themes: wires `@eldrajs/vite-plugin-theme`, the gateway client, draft
|
|
4
|
+
overlays and the Studio preview bridge into a Nuxt 4 site. It prerenders every published page and
|
|
5
|
+
dynamic route from the CMS, writes the generated `.eldra/manifest.json` and the CSP
|
|
6
|
+
`frame-ancestors` header the Studio preview bridge needs, and exposes `useEldraPage` for resolving
|
|
7
|
+
the current route's page/template/entry.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @eldrajs/theme-nuxt
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// nuxt.config.ts
|
|
17
|
+
export default defineNuxtConfig({
|
|
18
|
+
modules: ['@eldrajs/theme-nuxt'],
|
|
19
|
+
eldra: {
|
|
20
|
+
gatewayUrl: process.env.ELDRA_GATEWAY_URL,
|
|
21
|
+
orgId: process.env.ELDRA_ORG_ID,
|
|
22
|
+
studioOrigins: ['https://acme.eldracms.com'],
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import { EldraLayout } from '@eldrajs/theme-vue';
|
|
30
|
+
const { page, layout, blocks } = useEldraPage();
|
|
31
|
+
</script>
|
|
32
|
+
<template>
|
|
33
|
+
<main>
|
|
34
|
+
<EldraLayout v-if="page && layout" :layout="layout" :blocks="blocks" />
|
|
35
|
+
</main>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## `eldraRouteKey` — required on your `<NuxtPage>`
|
|
40
|
+
|
|
41
|
+
Give your `app.vue` the route key this module auto-imports:
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<!-- app/app.vue -->
|
|
45
|
+
<template>
|
|
46
|
+
<NuxtPage :page-key="eldraRouteKey" />
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This is not cosmetic on a **generated** site. `nuxi generate` writes each route as
|
|
51
|
+
`<route>/index.html`, and static hosts disagree about which URL that file lives at — some serve
|
|
52
|
+
`/products/ash-glaze-mug`, others answer it with a redirect to `/products/ash-glaze-mug/`. When the
|
|
53
|
+
URL the visitor lands on differs from the path the page was prerendered at, Nuxt re-navigates
|
|
54
|
+
between the two while the page hydrates; a catch-all page's default route key interpolates the
|
|
55
|
+
splat parameter, so those two spellings key differently and Vue destroys and re-creates the page —
|
|
56
|
+
and every block on it. Each block's `setup` then runs twice, so every read a commerce block makes
|
|
57
|
+
goes out twice. Only one of the two instances ever mounts, so nothing in the DOM gives it away.
|
|
58
|
+
|
|
59
|
+
`eldraRouteKey(route)` keys by the canonical path — the same identity `useEldraPage()` resolves
|
|
60
|
+
content under — so the move is a no-op. Themes scaffolded before this was added should add the
|
|
61
|
+
binding.
|
|
62
|
+
|
|
63
|
+
## Route resolution on a generated site
|
|
64
|
+
|
|
65
|
+
On a **static build in a browser**, `useEldraPage()` resolves routes from the build, not from the
|
|
66
|
+
gateway. `nuxi generate` ships the list of paths it prerendered (Nuxt's app manifest,
|
|
67
|
+
`/_nuxt/builds/meta/<buildId>.json`), and that list answers both questions the resolver used to ask
|
|
68
|
+
the gateway:
|
|
69
|
+
|
|
70
|
+
- **The path is in the build.** Its page, template and entry are in the `_payload.json` Nuxt's own
|
|
71
|
+
payload plugin loads in `router.beforeResolve`, before the page component exists — so a client
|
|
72
|
+
navigation between two prerendered routes renders the destination in the same tick, with `pending`
|
|
73
|
+
never true and no gateway read at all.
|
|
74
|
+
- **The path is not in the build.** It does not exist: `useEldraPage()` returns the empty route
|
|
75
|
+
(`page === null && template === null`) straight away, so the theme draws its not-found shell
|
|
76
|
+
without the five reads it used to take to conclude the same thing. A route published since the
|
|
77
|
+
build is not in the artifact either — publishing triggers a rebuild, which is what makes the build
|
|
78
|
+
the authority.
|
|
79
|
+
|
|
80
|
+
Three situations keep the old dynamic resolution, and are the reason the manifest is consulted
|
|
81
|
+
rather than assumed:
|
|
82
|
+
|
|
83
|
+
- **Studio preview.** Inside an allowed `studioOrigins` frame the route may be a draft, an
|
|
84
|
+
unpublished page or a path no build has ever contained, so every resolution is live — from the
|
|
85
|
+
first render, before the bridge has even said hello.
|
|
86
|
+
- **`nuxi dev`.** The dev server ships a manifest that prerendered nothing.
|
|
87
|
+
- **An SSR deployment** (`nuxt build` plus a Node server), for the same reason: nothing is in the
|
|
88
|
+
build, so an empty prerendered list means "this build prerendered nothing", never "this route does
|
|
89
|
+
not exist".
|
|
90
|
+
|
|
91
|
+
### A resolution that **failed** is not a route that is missing
|
|
92
|
+
|
|
93
|
+
The empty route above is an answer: there is no such page. A read the gateway could not answer is
|
|
94
|
+
not, and `useEldraPage()` keeps the two apart — a failed resolution carries `error` on the resolution
|
|
95
|
+
itself (`ResolvedEldraRoute.error`), so `error` is non-null while `page`/`template` are null and a
|
|
96
|
+
theme can draw its error branch instead of its not-found shell. The error lives on the resolution
|
|
97
|
+
rather than inside the composable because `useAsyncData` keeps **one** entry per route key and runs
|
|
98
|
+
only the first caller's handler: a theme that calls `useEldraPage()` twice on a page (a plugin for
|
|
99
|
+
the catalog route beside the page component) would otherwise see the failure in one call and an
|
|
100
|
+
ordinary empty route in the other.
|
|
101
|
+
|
|
102
|
+
**On the server such a route is answered `500`.** Nitro's prerenderer marks a non-200 route failed
|
|
103
|
+
before it writes anything, so a page the gateway could not be asked about is absent from the
|
|
104
|
+
artifact and named in the prerender log, instead of being written as the theme's not-found shell
|
|
105
|
+
under a path a visitor can reach. Pair it with `nitro.prerender.failOnError` if a build must not ship
|
|
106
|
+
without every page — the status alone turns a wrong page into a missing one, and that flag turns a
|
|
107
|
+
missing one into a failed build. Note the real exposure is about twice the route count: with
|
|
108
|
+
`crawlLinks: false` Nitro still prerenders each page's own `_payload.json`, which resolves the route
|
|
109
|
+
again.
|
|
110
|
+
|
|
111
|
+
A build with **no `ELDRA_GATEWAY_URL` / `ELDRA_ORG_ID`** is exempt from both: there every read fails
|
|
112
|
+
by definition, so such a route resolves to the plain empty route with no `error` and the theme
|
|
113
|
+
renders its static shell, which is the whole point of a scaffold build.
|
|
114
|
+
|
|
115
|
+
This is also why `eldraRouteKey` above is required rather than advisory: one page component per
|
|
116
|
+
canonical route is what lets the composable resolve the route its page is being created for. Nuxt
|
|
117
|
+
hands a page its own route through an injection private to Nuxt's app module, which a composable
|
|
118
|
+
shipped in a package cannot reach; `useEldraPage()` therefore reads the router's committed route and
|
|
119
|
+
pins it for the page's lifetime.
|
|
120
|
+
|
|
121
|
+
## When the gateway rate-limits the build
|
|
122
|
+
|
|
123
|
+
The gateway limits a client to a number of requests per minute. A `generate` of a real site is
|
|
124
|
+
thousands of reads from one address — every page, every route template, every catalog document,
|
|
125
|
+
times the site's locales, and roughly twice over because each page's `_payload.json` resolves its
|
|
126
|
+
route again — so a large build meets that limit routinely. The gateway's answer is `429`; with
|
|
127
|
+
`failOnError` set, one of them used to end the build.
|
|
128
|
+
|
|
129
|
+
**Nothing has to be configured for this.** Every gateway read — this module's own prerender reads,
|
|
130
|
+
the theme's reads at request time, and the platform read behind `commerce`/`locales` — retries an
|
|
131
|
+
idempotent request that answered `429` or `503` (and a dropped connection), honouring `Retry-After`
|
|
132
|
+
and otherwise backing off exponentially with jitter, five attempts including the first. A rate limit
|
|
133
|
+
is waited out rather than fought.
|
|
134
|
+
|
|
135
|
+
The knob exists for a gateway with an unusually narrow limit, or for a build that should fail fast:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
// nuxt.config.ts
|
|
139
|
+
eldra: {
|
|
140
|
+
// The defaults. `attempts` counts the first request; `{ attempts: 0 }` turns retrying off.
|
|
141
|
+
retry: { attempts: 5, baseDelayMs: 250, maxDelayMs: 5000 },
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
It is carried in the public runtime config, so a storefront that builds its own `@eldrajs/sdk`
|
|
146
|
+
client for commerce reads can hand it the same policy (`useRuntimeConfig().public.eldra.retry`) —
|
|
147
|
+
the starter does.
|
|
148
|
+
|
|
149
|
+
Two Nitro knobs sit beside it, and neither is this module's to set: `nitro.prerender.concurrency`
|
|
150
|
+
(**1** by default, which is already the gentlest setting — there is nothing to lower unless you have
|
|
151
|
+
raised it) and `nitro.prerender.retry`/`retryDelay` (3 × 500 ms by default), which re-render a route
|
|
152
|
+
whose response was one of ofetch's retryable statuses — 408, 409, 425, 429, 500, 502, 503, 504, and
|
|
153
|
+
so the 500 this module answers a failed resolution with, but not a 404.
|
|
154
|
+
|
|
155
|
+
**The new failure mode is a build that crawls, not one that fails.** A `Retry-After` is honoured up
|
|
156
|
+
to a minute, and `maxDelayMs` caps the _computed_ backoff rather than a wait the gateway asked for,
|
|
157
|
+
so four waits on a limit that keeps asking for a minute is about four minutes on **one** read —
|
|
158
|
+
times Nitro's own re-renders, at `concurrency: 1`, with no output and no error meanwhile. That is
|
|
159
|
+
the intent (a build that waits beats a build that fails), but it is the one thing nobody can
|
|
160
|
+
diagnose from the outside, so `retry: { attempts: 0 }` is the fail-fast lever: one request, and the
|
|
161
|
+
`429` surfaces the way it used to.
|
|
162
|
+
|
|
163
|
+
**The same policy governs reads a shopper triggers**, not only a build: the runtime plugin's client
|
|
164
|
+
serves SSR, a client-side route change and the Studio preview. A visitor who meets the rate limit on
|
|
165
|
+
a client-side navigation therefore waits — up to a minute on one `Retry-After` — where before they
|
|
166
|
+
were shown an error, which for a transient limit is the better of the two. A site that would rather
|
|
167
|
+
fail fast in the browser than wait can set a smaller `attempts`; the prerender reads use the same
|
|
168
|
+
value, so it is one trade-off, not two.
|
|
169
|
+
|
|
170
|
+
## Catalog-backed route templates
|
|
171
|
+
|
|
172
|
+
A route template whose `schemaApiId` is `catalog:product`, `catalog:collection` or
|
|
173
|
+
`catalog:category` is backed by the store's catalog rather than a CMS schema: the module prerenders
|
|
174
|
+
one route per active product, collection or category, and `useEldraPage()` resolves the object from
|
|
175
|
+
the path.
|
|
176
|
+
|
|
177
|
+
```vue
|
|
178
|
+
<script setup lang="ts">
|
|
179
|
+
const { template, entry, catalog, layout, blocks } = useEldraPage();
|
|
180
|
+
// catalog is { kind: 'product' | 'collection' | 'category', slug, path? } here, and null on every
|
|
181
|
+
// other route. `path` is set for a category and for nothing else.
|
|
182
|
+
// entry.data carries the binding paths a catalog template addresses —
|
|
183
|
+
// product: slug, title, description, status, categoryId, tags, variants[], images[]
|
|
184
|
+
// collection: slug, title, description, productCount, image
|
|
185
|
+
// category: slug, title, path, ancestors[], children[] (+ description as plain text, and
|
|
186
|
+
// productCount, when the catalog read carries them)
|
|
187
|
+
</script>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
A slug the catalog does not know resolves to the empty route, so the theme renders its not-found
|
|
191
|
+
shell. During generation a slug that cannot become a route is skipped with a warning naming it and
|
|
192
|
+
the build continues.
|
|
193
|
+
|
|
194
|
+
### Categories are nested, and canonical only
|
|
195
|
+
|
|
196
|
+
A category route's pattern ends in a **catch-all** parameter — `/categories/:path*` — and its
|
|
197
|
+
`slugField` is `path`. The parameter matches one or more segments and carries them joined with `/`:
|
|
198
|
+
a category's canonical path is the slugs of its ancestors, root first, then its own
|
|
199
|
+
(`/categories/billinn/bilstolar`).
|
|
200
|
+
|
|
201
|
+
There is no read that takes a path, so the whole category list is read once per request and the
|
|
202
|
+
path's segments are walked down the tree by slug. **Only the canonical path resolves** — a leaf on
|
|
203
|
+
its own, a wrong parent and a trailing extra segment are each the not-found shell rather than a
|
|
204
|
+
redirect — and the prerender pass generates exactly those canonical paths, one per category, times
|
|
205
|
+
the site's locales. A category the list cannot place (no slug, or a parent the list does not hold)
|
|
206
|
+
has no route at all, and neither has the subtree under it.
|
|
207
|
+
|
|
208
|
+
A `link` field pointing at a category resolves through the same path: `collectLinkTargets` reads the
|
|
209
|
+
tree whole for that reason, and a target it cannot place renders as plain text rather than as a link
|
|
210
|
+
to a path the site answers with its not-found shell.
|
|
211
|
+
|
|
212
|
+
`studioOrigins` must be explicit — this module never supplies a broad fallback origin for the
|
|
213
|
+
preview bridge. See [examples/starter-nuxt](../../examples/starter-nuxt) for a full theme and
|
|
214
|
+
[docs/themes.md](../../docs/themes.md) for the integration guide.
|
|
215
|
+
|
|
216
|
+
## What the store sells in
|
|
217
|
+
|
|
218
|
+
The module reads the organisation's commerce settings once, during the build, and puts them on the
|
|
219
|
+
runtime config beside the gateway URL and the org id. `StoreCommerce` is exported for exactly this,
|
|
220
|
+
so the key's shape is not re-declared per theme:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import type { StoreCommerce } from '@eldrajs/theme-nuxt/commerce';
|
|
224
|
+
|
|
225
|
+
const raw = (useRuntimeConfig().public.eldra as { commerce: StoreCommerce | null | '' }).commerce;
|
|
226
|
+
const commerce: StoreCommerce | null = typeof raw === 'object' ? raw : null;
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
`commerce` is `null` when the store has not configured commerce, when the site is built without
|
|
230
|
+
gateway credentials, or when the read failed — the build prints one warning (naming the cause when
|
|
231
|
+
there was one) and finishes, because a currency nobody can fetch should cost a symbol, not a deploy.
|
|
232
|
+
A theme that formats prices should treat that as "render a plain number", never as a currency to
|
|
233
|
+
guess at; the starter does exactly that in `app/storefront/money.ts`.
|
|
234
|
+
|
|
235
|
+
One detail of Nuxt's own serialisation matters when you read the key: a `null` public runtime-config
|
|
236
|
+
value reaches the page as an **empty string**, so on a store that published nothing `commerce` is
|
|
237
|
+
`''` rather than `null` (the module's `locale` does the same). Treat anything that is not an object
|
|
238
|
+
as "no currency" — not as a malformed record — and only complain about a record that is present but
|
|
239
|
+
incomplete.
|
|
240
|
+
|
|
241
|
+
The module supplies no override of its own, on purpose: the platform publishes the currency the
|
|
242
|
+
catalogue's prices are actually in, so a theme-side setting could only ever relabel real amounts.
|
|
243
|
+
(Nuxt's own public-runtime-config environment overriding — `NUXT_PUBLIC_ELDRA_COMMERCE_CURRENCY` and
|
|
244
|
+
its siblings — still applies wherever Nuxt reads runtime config at request time, as it does to every
|
|
245
|
+
other public key. On a prerendered site there is nothing for it to override: the value is baked into
|
|
246
|
+
each page's payload at build.) It is read at build rather than in the browser because every price on
|
|
247
|
+
a prerendered page is formatted against it.
|
|
248
|
+
|
|
249
|
+
## Which locales the site serves
|
|
250
|
+
|
|
251
|
+
The module reads the organisation's configured content locales once, during the build, and puts
|
|
252
|
+
them on the runtime config beside `commerce`. `StoreLocales` is exported for exactly this:
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
import type { StoreLocales } from '@eldrajs/theme-nuxt/locales';
|
|
256
|
+
|
|
257
|
+
const raw = (useRuntimeConfig().public.eldra as { locales: StoreLocales | null | '' }).locales;
|
|
258
|
+
const locales: StoreLocales | null = typeof raw === 'object' ? raw : null;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`locales` is `{ default, supported }` with `supported` default-first, or `null` — for an
|
|
262
|
+
organisation that has configured none, for a site built without gateway credentials, and for a read
|
|
263
|
+
that failed (that last one, and only that one, prints a warning naming the cause). `null` means the
|
|
264
|
+
site behaves exactly as it did before locales existed: one unprefixed site, no language switcher.
|
|
265
|
+
The same empty-string serialisation note as `commerce` applies, which is what the `typeof` guard
|
|
266
|
+
above is for.
|
|
267
|
+
|
|
268
|
+
A theme rarely needs to read the key itself: the module turns it into routing (see below) and
|
|
269
|
+
`useEldraLocale()` is the composable that answers "which locale is this page, and what are the
|
|
270
|
+
others".
|
|
271
|
+
|
|
272
|
+
## Locale-prefixed routing
|
|
273
|
+
|
|
274
|
+
With two or more locales the site serves the default locale at `/` and every other supported
|
|
275
|
+
locale under a path prefix — `/is-IS/products/ash-glaze-mug`. The first path segment selects the
|
|
276
|
+
locale (matched case-insensitively, canonicalised to the spelling the organisation stored) and the
|
|
277
|
+
rest of the path resolves exactly as it does unprefixed; every gateway read made for that page
|
|
278
|
+
carries that `locale`. `/<default-locale>/…` is deliberately **not** generated and resolves as an
|
|
279
|
+
unknown path, because the default locale lives at `/` only.
|
|
280
|
+
|
|
281
|
+
Path segments are not translated: a page is at its default-locale slug under every prefix, so
|
|
282
|
+
`/is-IS/about` is the Icelandic rendering of the same document `/about` serves. The prerender pass
|
|
283
|
+
therefore lists each content path once and writes it once per locale — pages, route templates,
|
|
284
|
+
catalog routes and the seeded `cart`/`wishlist`/`search` pages alike.
|
|
285
|
+
|
|
286
|
+
`eldra.locale` / `ELDRA_LOCALE` keeps the meaning it always had: an override of the **default**
|
|
287
|
+
locale. Naming one of the organisation's supported locales moves that locale to `/` and prefixes
|
|
288
|
+
the others; naming anything else (or deploying against an organisation with no locales) changes no
|
|
289
|
+
URL and still forwards the value on every read.
|
|
290
|
+
|
|
291
|
+
The module gives every page `<html lang>` and a `rel="alternate" hreflang` link per supported
|
|
292
|
+
locale (plus `x-default` for the unprefixed path) on its own — a theme adds nothing for either.
|
|
293
|
+
|
|
294
|
+
```vue
|
|
295
|
+
<script setup lang="ts">
|
|
296
|
+
// Auto-imported, like `useEldraPage`.
|
|
297
|
+
const { active, defaultLocale, supported, name, path, switchPath, select } = useEldraLocale();
|
|
298
|
+
|
|
299
|
+
// `path()` prefixes one same-site destination for the active locale, and is idempotent.
|
|
300
|
+
const cartHref = computed(() => path('/cart'));
|
|
301
|
+
// `switchPath()` is the same page in another language, query and fragment included;
|
|
302
|
+
// `select()` navigates there.
|
|
303
|
+
</script>
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
`name(locale)` is that locale's own name ("íslenska (Ísland)") for a switcher's option label. It is
|
|
307
|
+
resolved **once, on the server**, and carried in the payload: `Intl.DisplayNames` is ICU data and a
|
|
308
|
+
renderer and a browser need not have the same of it — Node answers "íslenska (Ísland)" for `is-IS`
|
|
309
|
+
where a reduced-ICU browser build answers "Icelandic (Iceland)" — so a page that let each side
|
|
310
|
+
compute its own labels would hydrate into a mismatch and repaint.
|
|
311
|
+
|
|
312
|
+
Links are already handled where the kit owns them: `useEldraLink()` resolves a `link` field's href
|
|
313
|
+
under the active locale, and a theme's router-link component should put every internal `to`
|
|
314
|
+
through `path()` once (the starter's `app/components/EldraRouterLink.vue` is the reference).
|
|
315
|
+
|
|
316
|
+
## Development
|
|
317
|
+
|
|
318
|
+
`src/runtime/**` is compiled by Nuxt at build/dev time, not by `tsc` — it imports `nuxt/app` and
|
|
319
|
+
Nuxt's virtual modules (`#imports`, `virtual:eldra/*`), which only exist inside a Nuxt build
|
|
320
|
+
graph. `tsconfig.json`'s `include` is narrowed to `src/index.ts` and `src/module.ts` (the module
|
|
321
|
+
entry, which only imports resolvable packages — and, through it, the framework-free runtime files
|
|
322
|
+
it shares with the composable) so `pnpm typecheck` proves the part `tsc` can
|
|
323
|
+
actually resolve; the runtime files that reach for Nuxt are still type-checked as part of
|
|
324
|
+
`nuxt-module-build build`
|
|
325
|
+
and by consuming Nuxt apps (see `examples/starter-nuxt`'s `nuxi typecheck`).
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
import { EldraRetryOptions } from '@eldrajs/theme-core';
|
|
3
|
+
import { ManifestRoute, DeclaredThemeCodePage, DeclaredSeed, ManifestTemplateRoles } from '@eldrajs/vite-plugin-theme';
|
|
4
|
+
import { LayoutBreakpoints } from '@eldrajs/theme-core/layout';
|
|
5
|
+
|
|
6
|
+
interface ModuleOptions {
|
|
7
|
+
gatewayUrl: string;
|
|
8
|
+
orgId: string;
|
|
9
|
+
studioOrigins: string[];
|
|
10
|
+
pageSchema: string;
|
|
11
|
+
routeTemplateSchema: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
routes?: ManifestRoute[];
|
|
14
|
+
customPages?: DeclaredThemeCodePage[];
|
|
15
|
+
/** What to seed a site with on its first deploy: route templates (at most 8)
|
|
16
|
+
* and static pages (`{ page: { slug }, title, blocks }`, at most 16) in one
|
|
17
|
+
* list. A seed is ignored once the site has a template for its route pattern,
|
|
18
|
+
* or a page with its slug, so nothing a merchant has edited is overwritten by
|
|
19
|
+
* a later deploy. */
|
|
20
|
+
templates?: DeclaredSeed[];
|
|
21
|
+
/** The block data behind the `header`/`footer` roles the declared
|
|
22
|
+
* `templates` layouts may reference. See that package's changelog for the
|
|
23
|
+
* validation rules. */
|
|
24
|
+
templateRoles?: ManifestTemplateRoles;
|
|
25
|
+
tailwind?: boolean;
|
|
26
|
+
/** The theme's own tablet/normal layout breakpoints (min-width px), so
|
|
27
|
+
* Studio's UI can react to the theme's actual ranges (its side panels
|
|
28
|
+
* overlay the preview at `tablet + 100`px) instead of a value the theme
|
|
29
|
+
* may not share. Resolved and validated in @eldrajs/theme-core
|
|
30
|
+
* (resolveLayoutBreakpoints) — an invalid pair falls back to the defaults
|
|
31
|
+
* (768/1024) with a console warning rather than failing the build.
|
|
32
|
+
* Reaches both the layout stylesheet and `theme:ready` via the theme
|
|
33
|
+
* manifest (`virtual:eldra/manifest`), the one resolved value every
|
|
34
|
+
* consumer reads. */
|
|
35
|
+
breakpoints?: LayoutBreakpoints;
|
|
36
|
+
/**
|
|
37
|
+
* How hard every gateway read tries again when the gateway says "not now" —
|
|
38
|
+
* a `429` from its rate limit, a `503` while it restarts, a dropped
|
|
39
|
+
* connection. Defaults to five attempts with exponential backoff and jitter,
|
|
40
|
+
* honouring `Retry-After`; `{ attempts: 0 }` turns it off.
|
|
41
|
+
*
|
|
42
|
+
* It is what keeps a static build of a large site alive: a `nuxi generate`
|
|
43
|
+
* is thousands of reads from one address, which is enough to meet a
|
|
44
|
+
* per-minute rate limit, and with `nitro.prerender.failOnError` set (as it
|
|
45
|
+
* should be) one refusal ends the build. Reaches **both** transports — this
|
|
46
|
+
* module's own prerender reads and the theme's at request time
|
|
47
|
+
* (`@eldrajs/theme-core`), and the platform read behind `commerce`/`locales`
|
|
48
|
+
* (`@eldrajs/sdk`) — and is carried in the public runtime config, so a
|
|
49
|
+
* storefront building its own commerce client reads the same policy.
|
|
50
|
+
*/
|
|
51
|
+
retry?: EldraRetryOptions;
|
|
52
|
+
}
|
|
53
|
+
declare const eldraModule: NuxtModule<ModuleOptions>;
|
|
54
|
+
|
|
55
|
+
export { eldraModule as default };
|
|
56
|
+
export type { ModuleOptions };
|