@shopbite-de/storefront 2.2.0 → 2.3.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 (61) hide show
  1. package/CLAUDE.md +11 -6
  2. package/app/app.vue +9 -6
  3. package/app/components/Category/Breadcrumb.vue +9 -10
  4. package/app/components/Category/Listing.vue +0 -1
  5. package/app/components/Checkout/Summary.vue +27 -2
  6. package/app/components/Header.vue +2 -2
  7. package/app/components/Menu/BonCard.vue +0 -13
  8. package/app/components/Product/FoodLabels.vue +47 -20
  9. package/app/components/Product/QuickView.vue +1 -1
  10. package/app/components/Sb/Icon.vue +3 -1
  11. package/app/composables/useBusinessHours.ts +35 -14
  12. package/app/composables/useHolidays.ts +31 -11
  13. package/app/composables/useHomeMenuCategories.ts +6 -34
  14. package/app/composables/useLiveShopData.ts +17 -0
  15. package/app/composables/useNavigation.ts +14 -66
  16. package/app/composables/useNavigationSearch.ts +8 -31
  17. package/app/composables/useRestaurantSchema.ts +2 -13
  18. package/app/composables/useSeoUrlRoute.ts +21 -0
  19. package/app/composables/useShopBiteConfig.ts +50 -6
  20. package/app/composables/useTopSellers.ts +2 -43
  21. package/app/error.vue +4 -0
  22. package/app/utils/product.ts +1 -62
  23. package/docs/notes/2026-09-10-issue-275-accessibility.md +2 -2
  24. package/docs/notes/2026-09-12-issue-327-home-hero.md +1 -1
  25. package/docs/notes/2026-09-13-issue-332-home-info-cards.md +1 -3
  26. package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +1 -1
  27. package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +1 -1
  28. package/docs/notes/2026-09-23-issue-388-home-sections.md +2 -2
  29. package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +1 -1
  30. package/modules/theme.ts +1 -1
  31. package/nuxt.config.ts +13 -0
  32. package/package.json +5 -5
  33. package/server/api/_cache/purge.post.ts +6 -3
  34. package/server/api/breadcrumb/[categoryId].get.ts +31 -0
  35. package/server/api/navigation/[type].get.ts +97 -0
  36. package/server/api/payment-methods.get.ts +29 -0
  37. package/server/api/seo-url/index.get.ts +17 -0
  38. package/server/api/seo-url/known.get.ts +33 -0
  39. package/server/api/shopbite/business-hours.get.ts +22 -0
  40. package/server/api/shopbite/config.get.ts +6 -0
  41. package/server/api/shopbite/holidays.get.ts +20 -0
  42. package/server/api/top-sellers.get.ts +59 -0
  43. package/server/utils/backoff.ts +67 -0
  44. package/server/utils/cachePurge.ts +45 -12
  45. package/server/utils/menuRoot.ts +24 -18
  46. package/server/utils/seoPaths.ts +130 -0
  47. package/server/utils/seoUrlCache.ts +98 -0
  48. package/server/utils/shopBiteConfig.ts +30 -0
  49. package/server/utils/storeApi.ts +22 -0
  50. package/test/layer/nuxt.config.ts +1 -1
  51. package/test/nuxt/CheckoutSummary.test.ts +38 -2
  52. package/test/nuxt/ProductFoodLabels.test.ts +70 -0
  53. package/test/nuxt/liveShopData.test.ts +114 -0
  54. package/test/nuxt/useShopBiteConfig.test.ts +22 -0
  55. package/test/nuxt/useTopSellers.test.ts +10 -27
  56. package/test/unit/cachePurge.spec.ts +41 -0
  57. package/test/unit/layoutCacheRoutes.spec.ts +566 -0
  58. package/test/unit/nitroStubs.ts +99 -0
  59. package/test/unit/product.spec.ts +1 -23
  60. package/test/unit/seoPaths.spec.ts +117 -0
  61. package/app/components/Menu/FoodLabelLegend.vue +0 -28
package/CLAUDE.md CHANGED
@@ -32,6 +32,10 @@ pnpm load-schema # Reload Shopware API schema
32
32
 
33
33
  pnpm 12 (pinned in `package.json`, CI and `node.dockerfile`). Settings live in `pnpm-workspace.yaml` (`.npmrc` is auth/registry only since pnpm 11). pnpm 12 rejects packages published less than 24 hours ago (`minimumReleaseAge`), also in an existing lockfile; update dependencies with pnpm 12 itself, not an older global pnpm (`docs/notes/2026-09-21-dependency-update.md`).
34
34
 
35
+ ### Test-driven development
36
+
37
+ Work test-first (red, green, refactor): for a bug, first write a test that reproduces it and fails on the current code, then fix it; for new behaviour, write the tests that describe it before the implementation. The test lands in the same commit as the change it covers. Changes with nothing to assert (content, copy, styling, dependency bumps) skip this; say so in the commit message.
38
+
35
39
  ### Running a single test
36
40
 
37
41
  ```bash
@@ -90,7 +94,7 @@ Key custom composables:
90
94
  - **`useDeliveryTime`** – validates slots in 5-minute increments, accounts for `deliveryMinutes` (default 30), handles holidays
91
95
  - **`useAddToCart`** – products with extras/toppings use UUID v5 (product ID + sorted extras) as container item reference; simple products bypass the container
92
96
  - **`useAddressAutocomplete`** – proxies Geoapify through `/api/address/autocomplete` to avoid exposing the API key client-side
93
- - **`useShopBiteConfig`** – fetches delivery config and checkout state from the custom Shopware plugin
97
+ - **`useShopBiteConfig`** – fetches delivery config and checkout state from the custom Shopware plugin; the server renders from the cached `/api/shopbite/config` (60 s), the browser loads it from Shopware after hydration (`useLiveShopData`) and the checkout every 10 s (`Checkout/Summary.vue`). The plugin does not enforce the checkout switch, so the browser's value is the gate and must come from Shopware
94
98
  - **`useWishlistEntries`** – the wishlist (#467): an entry is a configured dish (product/variant id + number, `without`, `extras`, the quick view configuration of #411). Customers keep entries in the ShopBite plugin (`/store-api/shopbite/wishlist`, `/add`, `/merge`, `DELETE /{id}`, entity `shopbite_wishlist_item`, shopware-plugin#30), guests in localStorage `shopbite-wishlist` (old `sw-wishlist-items` ids are taken over). `app.vue` loads it on mount and on login merges the guest entries into the account (logout reloads the guest's); a backend without the routes (404) keeps customers in localStorage. On the first load a customer's Shopware core wishlist moves into the plugin and is deleted there. `WishlistSaveButton` (heart in the product sheet header, `aria-pressed` for the current configuration) gets the selection from `ProductDetail` (`selection-changed`); `Wishlist.vue` adds rows with `useAddToCart` (same container line item as the sheet) and opens the sheet on the wishlist page with the saved configuration ("Anpassen").
95
99
  - **`useSyncWishlist`** – deliberate override of the layer composable (copy of `@shopware/composables` 1.13.0) that does not log the expected 404/403 of a missing or disabled wishlist (#366); only the layer's own `useWishlist` still uses it since #467; compare with the layer source when Renovate bumps `@shopware/composables`
96
100
 
@@ -98,11 +102,11 @@ Key custom composables:
98
102
 
99
103
  The storefront reads plain Shopware entities with fixed names; seed data must match them exactly (`shopware/scripts/seed-demo-menu.py` is a working example):
100
104
 
101
- - **Navigation:** menu sections are the children of the sales channel navigation root (`readNavigation main-navigation`), scoped to the menu root: `runtimeConfig.public.shopBite.menuCategoryId` if set, else `menuCategoryId` from `/store-api/shopbite/config` (plugin configuration per sales channel, #486). Always resolve it through `useMenuRootId()` (app) or `menuRootId()` (server), never read the env directly. Category icon comes from the custom field `shopbite_category_icon` (icones.js.org name such as `i-lucide-pizza`), set by the ShopBite plugin.
105
+ - **Navigation:** menu sections are the children of the sales channel navigation root (`readNavigation main-navigation`), scoped to the menu root: `runtimeConfig.public.shopBite.menuCategoryId` if set, else `menuCategoryId` from `/store-api/shopbite/config` (plugin configuration per sales channel, #486). Always resolve it through `menuRootId()` (server, falls back to the navigation root), `menuRootIdStrict()` (server, rejects without the plugin config; the cached navigations `menu` and `home` of `/api/navigation/[type]` use it, resolved once per request on `event.context` for key and fetch, so a fallback menu or one root's sections under another root's key is never cached) or `useMenuRootId()` (app, kept for shops), never read the env directly. Both server variants read the cached plugin config (`shopBiteConfig()`, `server/utils/shopBiteConfig.ts`), which keeps the last good config when Shopware fails and asks again only after 30 s. Category icon comes from the custom field `shopbite_category_icon` (icones.js.org name such as `i-lucide-pizza`), set by the ShopBite plugin.
102
106
  - **Property groups:** `Hauptzutaten` (ingredients on the card, deselectable on the detail page, removed ones are appended to the cart label with "-"), `Vegetarisch` and `Vegan` with the option `Ja` (diet badges), `Küche` (kitchen badge). Filterable groups appear as listing filters.
103
107
  - **Extras:** product cross-sellings of type `productList`; the cross-selling name is the label ("Extras", "Beilagen"), the assigned products need a price and sales-channel visibility but no category. In the quick view each cross-selling is a collapsible checkbox list that shows 6 entries of a long list and a search field above 15 entries (`Product/CrossSelling.vue`). Selected extras are sent as children of a `container` line item (`useAddToCart.ts`, handled by the ShopBite plugin). The bon card opens the quick view sheet (`Product/QuickView.vue`), whose state is the `produkt` query parameter (product number) via `useProductQuickView` (#325). That deep link is the product URL (#289, no product pages): `productDeepLink()` (`app/utils/productUrl.ts`) takes the product SEO URL when it carries `?produkt=` (the ShopBite plugin sets the template, shopware-plugin#28; the number must be `|url_encode|raw` in the template, the SEO escaper slugifies `ß`) and otherwise builds it from the category SEO URL. The card name is a stretched link to it (a plain click stays in place); a number not in the list (a variant) is loaded and opens with its options selected. The quick view keeps its configuration in the URL (#411): `ohne` (deselected ingredients by name) and `extras` (extras by product number), written live with `router.replace` by `useQuickViewConfiguration`; a variant switch updates `produkt` without swapping the sheet's product (numbers the sheet switched to itself are pinned). The share button (`useShareLink`) uses the Web Share API, else copies the link.
104
108
  - **Custom fields on products:** `shopbite_receipt_print_type` (`number` prints the menu number on the receipt, `label` prints the name) and `shopbite_delivery_time_factor` (int) and `shopbite_cart_upsell` (bool, suggests the product on the order confirmation step `/bestellung/bestaetigen` via `useCartUpsell`; variant parents are never suggested, a flag on a parent applies to its variants), all from the ShopBite plugin.
105
- - **Allergens and additives (#485):** property groups `Allergene` and `Zusatzstoffe` from the ShopBite plugin (shopware-plugin#36, maintained in the backoffice), code in the option custom field `shopbite_code` (A-R, 1-12), product custom field `shopbite_allergens_checked` = lists complete. `getFoodLabels()`/`foodLabelCodes()`/`foodLabelText()`/`foodLabelLegend()` in `app/utils/product.ts`. The bon card shows the codes (names for screen readers), `Menu/FoodLabelLegend.vue` explains the codes used in the list (native `<details>`), `Product/FoodLabels.vue` writes them out in the sheet; without `shopbite_allergens_checked` the sheet points to the restaurant's phone and never says "no allergens". **Includes filter `translated` too:** custom fields only come back when `customFields` is in the `product` and `property_group_option` includes (listing, search, product route, quick view, top sellers).
109
+ - **Allergens and additives (#485):** property groups `Allergene` and `Zusatzstoffe` from the ShopBite plugin (shopware-plugin#36, maintained in the backoffice), code in the option custom field `shopbite_code` (A-R, 1-12), product custom field `shopbite_allergens_checked` = lists complete. `getFoodLabels()`/`foodLabelText()`/`allergensChecked()` in `app/utils/product.ts`. Shown only on request (#500): the bon card and the list show nothing, `Product/FoodLabels.vue` is an info button in the sheet's toolbar that opens a Reka popover (not teleported, so the dialog's focus trap holds) with the names written out; without `shopbite_allergens_checked` the sheet points to the restaurant's phone and never says "no allergens". **Includes filter `translated` too:** custom fields only come back when `customFields` is in the `product` and `property_group_option` includes (listing, search, product route, quick view, top sellers).
106
110
  - **Variants:** standard configurator settings (`Product/Configurator.vue`); `server/api/product/variant.get.ts` resolves a variant by option ids.
107
111
 
108
112
  ### Server routes
@@ -115,6 +119,7 @@ The storefront reads plain Shopware entities with fixed names; seed data must ma
115
119
  Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): fatal only in the browser, because a fatal error makes Nitro log a `[request error] [fatal]` block per scanner request (#363).
116
120
  `modules/dev-tooling.ts` registers `@nuxt/eslint`, `@nuxt/hints` and `@nuxt/test-utils/module` only when the storefront itself is the project (not for shops extending the layer, not inside `node_modules`); they are devDependencies, so never add them to `modules` in `nuxt.config.ts` (#378).
117
121
  The cached Store API handlers (`defineCachedEventHandler`, TTL `public.shopBite.cacheTtl`, a day for products, listings, categories) can be emptied by the backoffice: `POST /api/_cache/purge` with `Authorization: Bearer $NUXT_CACHE_PURGE_SECRET` (route off without the secret, #484). `server/utils/cachePurge.ts` picks the Nitro keys (`cache:nitro:handlers:<name>:<escaped key>`) by id, so a new cached handler needs its `name` in `ALL` there and the id in its `getKey`.
122
+ Layout data is cached the same way, because every page renders it, a 404 too (once its own page and once `/__nuxt_error`): a vulnerability scanner probing 404 paths otherwise multiplied its request rate at Shopware many times over. With warm caches an SSR request asks Shopware only for `/context` (per visitor: cart, login); paths with non-ASCII characters that pass the known-path filter still make their SEO lookups uncached, and the browser loads config, hours and holidays once per page load (below). Handlers and TTLs (`cacheTtl.*`, `NUXT_PUBLIC_SHOP_BITE_CACHE_TTL_*`): `/api/navigation/[type]` (`main`, `footer`, `menu`, `home`; key includes the menu root; `navigation`, a day), `/api/breadcrumb/[categoryId]` (`category`; an empty breadcrumb, i.e. an unknown id, is a 404 and not cached), `/api/top-sellers` (`listing`), `/api/payment-methods` (Restaurant schema, asked without a visitor context; `paymentMethods`, 1 h), `/api/shopbite/config` (cached function `shopbite-config`, `config`, 60 s), `/api/shopbite/business-hours` and `/holidays` (`businessHours`/`holidays`, 5 min), `/api/seo-url?path=` (function `seo-url`, `seoUrl`, 10 min; key = lookup field (`pathInfo` for technical URLs, else `seoPathInfo`) + lower-cased value; only matches that spell the looked-up value up to case are stored, because Shopware's collation also ignores accents and trailing spaces and each such variant would add an entry). Config, hours, holidays and the SEO caches use `swr: false`: with Nitro's default `swr: true` an expired entry is still served once, so the TTL would not cap the staleness. A failed Shopware request is never cached. During an outage the layout handlers and `shopBiteConfig()` serve the last good answer per key and otherwise fail fast with 503; after a failure each handler asks Shopware again only after 30 s (`createResilientLoader`, `server/utils/backoff.ts`), and `storeApiGet`/`storeApiPost` do not retry (ofetch retries a GET once by default). Use the loader in a new cached handler. Before an order, `Checkout/Summary.vue` asks Shopware for the checkout switch (`checkCheckoutEnabled`) and does not order when it is off or cannot be checked. Only server-side rendering reads config, hours and holidays from the cache: `useAsyncData` reuses the server payload at hydration (a `refresh()` during hydration does not fetch either), so `useLiveShopData` (app.vue, error.vue) reloads the three keys from Shopware with `refreshNuxtData` after hydration; store status, delivery time choice and order buttons then act on that. Keys contain no language or context: like all cached handlers they call Shopware with the sales channel's access key only. Every purge (any target) empties the layout handlers (`LAYOUT`), the lists and the cached functions `seo-url`, `seo-paths`, `shopbite-config`; `{ "layout": true }` empties only the layout data (and `llms.txt`), for changes of hours, closing days or the checkout switch.
118
123
 
119
124
  `modules/public-cache.ts` (local module, also active in shops extending the layer) adds a 30-day `Cache-Control` route rule for every file in the `public/` folders of all layers; Nitro serves them without one. `image.ipx.maxAge` gives resized logos the same lifetime. Replace a public file under a new name (#273).
120
125
  `server/api/content/*.get.ts` — Nuxt Content queries for the pages. Do not call `queryCollection()` in page code: in the browser it downloads the SQLite WASM build (865 KB) on client-side navigation (#314).
@@ -133,7 +138,7 @@ The cached Store API handlers (`defineCachedEventHandler`, TTL `public.shopBite.
133
138
 
134
139
  ### Style presets and base components (#439–#446)
135
140
 
136
- - Every shop has a style preset: `trattoria` (default), `grill` (dark) or `asia`. `shopBite.preset` in nuxt.config.ts (or `NUXT_SHOPBITE_PRESET` at build time) sets the default, `shopBite.colors` overrides tokens of that preset (the build warns when a pair misses WCAG AA). `modules/theme.ts` writes the stylesheets of all presets into the build (`.nuxt/shopbite-theme.css`, each scoped to `:root[data-preset=…]`) and registers their fonts (listed before `@nuxt/fonts`; browsers fetch only the faces in use). The active preset is runtime config `shopBite.themePreset` (`NUXT_PUBLIC_SHOP_BITE_THEME_PRESET`): `useThemePreset()` returns `preset`, `menuView` and `colorMode` (from `THEME_PRESETS`), `plugins/theme-preset.ts` sets `data-preset` on `<html>`. One build serves every preset; the lead demos rely on it. `shopBite.logoUrl` (`NUXT_PUBLIC_SHOP_BITE_LOGO_URL`) replaces the header logo files (`public/light|dark/Logo.png`, chosen by the preset's colour mode).
141
+ - Every shop has a style preset: `trattoria` (default), `grill` (dark) or `asia`. `shopBite.preset` in nuxt.config.ts (or `NUXT_SHOPBITE_PRESET` at build time) sets the default, `shopBite.colors` overrides tokens of that preset (the build warns when a pair misses WCAG AA). `modules/theme.ts` writes the stylesheets of all presets into the build (`.nuxt/shopbite-theme.css`, each scoped to `:root[data-preset=…]`) and registers their fonts (listed before `@nuxt/fonts`; browsers fetch only the faces in use). The active preset is runtime config `shopBite.themePreset` (`NUXT_PUBLIC_SHOP_BITE_THEME_PRESET`): `useThemePreset()` returns `preset`, `menuView` and `colorMode` (from `THEME_PRESETS`), `plugins/theme-preset.ts` sets `data-preset` on `<html>`. One build serves every preset, so a single image can run several shops. `shopBite.logoUrl` (`NUXT_PUBLIC_SHOP_BITE_LOGO_URL`) replaces the header logo files (`public/light|dark/Logo.png`, chosen by the preset's colour mode).
137
142
  - Components style only with the `--sb-*` colour tokens and `--font-sb-display`/`--font-sb-body` (the `--font` prefix makes @nuxt/fonts resolve the family and add metric fallbacks) through the `sb-*` utilities (`bg-sb-surface`, `text-sb-ink-muted`, `font-display`, `rounded-sb-control`). No colour mode switch: the preset fixes light or dark.
138
143
  - Base components live in `app/components/Sb/` (`SbButton`, `SbIconButton`, `SbSegmentedControl`, `SbSheet`, `SbChoiceGroup`, `SbCheckbox`, `SbField` + `SbInput`, `SbSelect` (native), `SbStepper`, `SbChip`, `SbStatusPill`, `SbStars`, `SbConfirmDialog`, `SbIcon` with inline stroke icons). Behaviour and accessibility come from Reka UI (radio groups, checkbox, dialog and alert dialog with focus trap). Every control is at least 44 px and has a visible focus ring; icon-only buttons need a `label`; toggles use `aria-pressed` with a stable name. Hide a base component responsively with a wrapper (`<span class="hidden sm:block">`): its own `inline-flex` wins over a `hidden` passed as class. Elements focused only by script (`tabindex="-1"`) get no focus ring. Entry animations go behind `motion-safe:` (a `motion-reduce:animate-none` loses against `data-[state=open]:animate-…`).
139
144
  - No toasts (removed in #445, other responses to be designed): results and errors show where they happen, e.g. `role="alert"` boxes in forms and the checkout, `role="status"` regions, the voucher error at its field.
@@ -151,11 +156,11 @@ The cached Store API handlers (`defineCachedEventHandler`, TTL `public.shopBite.
151
156
  - `server/plugins/site-url.ts` makes `storeUrl` the nuxt-site-config URL, so canonical, sitemap and robots.txt share one base. Build absolute URLs with `toAbsoluteUrl(useSiteConfig().url, path)` (`app/utils/seo.ts`).
152
157
  - `app.vue` sets the title template (`site.titleTemplate`), canonical from the route, `og:url`, fallback `og:image` (`site.ogImage`) and `twitter:card`. Page titles are plain (`"Warenkorb"`), never suffixed with the shop name. Indexable pages use `usePageSeo` (`standalone: true` skips the template, home page); categories use `useCategorySeo`, which overrides the canonical with the SEO URL.
153
158
  - Shopware category SEO URLs end in `/` and 404 without it, but the sitemap module strips trailing slashes from every URL. Sitemap entries that need the slash carry `_trailingSlash: true`; `server/plugins/sitemap-trailing-slash.ts` restores it in the XML. Never normalise trailing slashes of backend SEO URLs.
154
- - There are no category page routes: the catch-all `pages/[...all].vue` serves Markdown content pages first and otherwise the category SEO URL of the path, whatever prefix the Shopware template gives it (`/c/Pizza/`, `/speisekarte/pizza/`); paths with a file extension 404 without a backend request. It resolves the path with `useSeoUrlRoute` (category SEO URLs only, product SEO URLs 404, #289), which redirects (301) aliases to the SEO URL: other casing, toggled trailing slash, and old SEO URLs that Shopware keeps after a template or name change (`isCanonical: null`). The Store API hides old SEO URLs unless the criteria filter on `isCanonical` explicitly, so `resolvePath` never finds them; `resolveOldPath` looks them up separately, only for unknown paths.
159
+ - There are no category page routes: the catch-all `pages/[...all].vue` serves Markdown content pages first and otherwise the category SEO URL of the path, whatever prefix the Shopware template gives it (`/c/Pizza/`, `/speisekarte/pizza/`); paths with a file extension 404 without a backend request. It resolves the path with `useSeoUrlRoute` (category SEO URLs only, product SEO URLs 404, #289), which redirects (301) aliases to the SEO URL: other casing, toggled trailing slash, and old SEO URLs that Shopware keeps after a template or name change (`isCanonical: null`). The Store API hides old SEO URLs unless the criteria filter on `isCanonical` explicitly, so `resolvePath` never finds them; `resolveOldPath` looks them up separately, only for unknown paths. `resolvePath` asks `/api/seo-url`, which caches matches only (a cached miss per scanner path would grow the cache without bound); before any lookup the server asks `/api/seo-url/known`, which checks the path against all current and old category SEO paths (`server/utils/seoPaths.ts`: decoded with `decodeURIComponent`, lower case, without accents, `ß`/`æ`/`œ` written out, without outer slashes; a key with non-ASCII characters or `%` is always let through, since MySQL's collation may match it; list cached as `seo-paths`, `cacheTtl.seoUrl`, paged with `page`, which `/seo-url` honours, not `p`, sorted by `id`) and answers a path no category ever had with a 404 without four backend lookups. Paths no SEO URL can have get a 404 (and `/api/seo-url` answers null) without any lookup (`isHostilePath`): undecodable or invalid UTF-8, `%25`, `..`, technical prefixes not followed by a 32-hex id. Operator caveat: a section created or renamed in the Shopware Administration without a purge 404s at its new URL until the list expires (`cacheTtl.seoUrl`, 10 min); the backoffice purge or any `POST /api/_cache/purge` fixes it at once, `NUXT_PUBLIC_SHOP_BITE_CACHE_TTL_SEO_URL` shortens the window. More than 1000 entries per kind is cached as "no filtering"; a failed load lets every path through for 30 s without asking again.
155
160
  - `@nuxtjs/sitemap` must stay before `@nuxt/content` in `modules`; content collections need the `sitemap` schema field to appear in the sitemap.
156
161
  - The home page FAQ (`faq` in `content/index.yml`, `Home/Faq.vue`, #404) uses native `<details>`, not a Reka accordion, which unmounts closed panels, and the answers must be in the SSR HTML. The same items feed the `FAQPage` JSON-LD and `/llms.txt`.
157
162
  - `server/plugins/ai-crawlers.ts` adds two named robots.txt groups via the `robots:config` hook (#403): AI search/assistant bots and AI training bots (lists with sources in `server/utils/aiCrawlers.ts`), toggled by `runtimeConfig.aiCrawlers.search`/`.training`. A crawler matching a named group ignores `*`, so allowed groups repeat the `robots.disallow` paths.
158
- - Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`; `alternateNames` lists other names the shop is listed under, for the Restaurant schema `alternateName` and `/llms.txt`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
163
+ - Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`; `alternateNames` lists other names the shop is listed under, for the Restaurant schema `alternateName` and `/llms.txt`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (during SSR they read the cached `/api/shopbite/*` routes, after hydration `useLiveShopData` loads them from Shopware); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
159
164
 
160
165
  ### Layer imports
161
166
 
package/app/app.vue CHANGED
@@ -33,10 +33,14 @@ if (sessionContextData.value) {
33
33
  useSessionContext(sessionContextData.value);
34
34
  }
35
35
 
36
- // Business hours and holidays feed the store status in the header
37
- // (HeaderStoreStatus) and the delivery time selection.
38
- const { refresh: refreshBusinessHours } = useBusinessHours();
39
- const { refresh: refreshHolidays } = useHolidays();
36
+ // Business hours, holidays and the checkout switch feed the store status
37
+ // (HeaderStoreStatus), the delivery time selection and the order buttons.
38
+ // The server renders them from its caches; after hydration the browser
39
+ // loads them from Shopware (useLiveShopData).
40
+ useBusinessHours();
41
+ useHolidays();
42
+ useShopBiteConfig();
43
+ useLiveShopData();
40
44
 
41
45
  const { refreshCart } = useCart();
42
46
  // Wishlist entries (#467): loaded in the browser, not during SSR. A login
@@ -50,8 +54,7 @@ watch(isLoggedIn, (loggedIn, before) => {
50
54
  else loadWishlist();
51
55
  });
52
56
 
53
- onMounted(async () => {
54
- await Promise.all([refreshHolidays(), refreshBusinessHours()]);
57
+ onMounted(() => {
55
58
  refreshCart();
56
59
  });
57
60
 
@@ -7,8 +7,6 @@ const props = defineProps<{
7
7
 
8
8
  const { categoryId } = toRefs(props);
9
9
 
10
- const { apiClient } = useShopwareContext();
11
-
12
10
  const breadcrumbJsonLd = ref<object | null>(null);
13
11
 
14
12
  useHead(() => ({
@@ -27,14 +25,15 @@ const cacheKey = computed(() => `breadcrumb-${categoryId.value}`);
27
25
 
28
26
  const { data } = await useAsyncData(cacheKey, async () => {
29
27
  if (!categoryId.value) return [];
30
- const response = await apiClient.invoke(
31
- "readBreadcrumb get /breadcrumb/{id}",
32
- {
33
- pathParams: { id: categoryId.value },
34
- query: { type: "category" },
35
- },
36
- );
37
- return response.data;
28
+ // cached on the server (server/api/breadcrumb); 404 = empty breadcrumb
29
+ try {
30
+ return await $fetch<Schemas["BreadcrumbCollection"]>(
31
+ `/api/breadcrumb/${categoryId.value}`,
32
+ );
33
+ } catch (error) {
34
+ if ((error as { statusCode?: number }).statusCode === 404) return [];
35
+ throw error;
36
+ }
38
37
  });
39
38
 
40
39
  const items = computed<{ label?: string; to: string }[]>(() => {
@@ -275,7 +275,6 @@ async function openFilterDrawer() {
275
275
  @select="quickView.show"
276
276
  />
277
277
  </div>
278
- <MenuFoodLabelLegend v-if="!showSkeleton" :products="elements" />
279
278
  <LazyProductQuickView
280
279
  v-if="quickView.mounted.value"
281
280
  v-model:open="quickView.open.value"
@@ -7,7 +7,8 @@ const { createOrder, selectedPaymentMethod, selectedShippingMethod } =
7
7
  useCheckout();
8
8
  const { refreshCart } = useCart();
9
9
  const { isLoggedIn, isGuestSession, refreshUser } = useUser();
10
- const { isCheckoutEnabled, refresh } = useShopBiteConfig();
10
+ const { isCheckoutEnabled, refresh, checkCheckoutEnabled } =
11
+ useShopBiteConfig();
11
12
  const { trackOrder } = useTrackEvent();
12
13
  const { isLoading: isLoadingOpeningHours, hasFailed: hasOpeningHoursFailed } =
13
14
  useOpeningHoursData();
@@ -89,10 +90,34 @@ async function hasAvailableCheckoutMethods(): Promise<boolean> {
89
90
  return false;
90
91
  }
91
92
 
93
+ /**
94
+ * The checkout switch as Shopware has it now: the page may still show the
95
+ * value of the server render, and the plugin accepts orders regardless.
96
+ */
97
+ async function isCheckoutStillEnabled(): Promise<boolean> {
98
+ const enabled = await checkCheckoutEnabled();
99
+ if (enabled) return true;
100
+ reportError(
101
+ enabled === false
102
+ ? {
103
+ title: "Bestellung nicht möglich",
104
+ description:
105
+ "Es werden aktuell keine weiteren Bestellungen mehr aufgenommen.",
106
+ }
107
+ : {
108
+ title: "Bestellung nicht möglich",
109
+ description:
110
+ "Ob gerade Bestellungen angenommen werden, konnte nicht geprüft werden. Bitte versuche es in einem Moment erneut.",
111
+ },
112
+ );
113
+ return false;
114
+ }
115
+
92
116
  async function handleCreateOrder() {
93
117
  isPlacingOrder.value = true;
94
118
  orderError.value = null;
95
119
  try {
120
+ if (!(await isCheckoutStillEnabled())) return;
96
121
  if (!(await hasAvailableCheckoutMethods())) return;
97
122
 
98
123
  const order = await createOrder({
@@ -180,7 +205,7 @@ const checkoutButtonLabel = computed<string>(() => {
180
205
  return "Bitte zuerst Ihre Angaben speichern";
181
206
  }
182
207
 
183
- // app.vue loads business hours and holidays after mounting. Until then (or
208
+ // app.vue loads business hours and holidays after hydration. Until then (or
184
209
  // when that fails) an invalid time says nothing about the shop being closed
185
210
  // (#349, #355).
186
211
  if (isLoadingOpeningHours.value) {
@@ -10,8 +10,8 @@ import { useUser } from "@shopware/composables";
10
10
  const { mainMenu } = useNavigation(false);
11
11
  const { site, shopBite } = useRuntimeConfig().public;
12
12
  const { colorMode } = useThemePreset();
13
- // A logo URL from runtime config (NUXT_PUBLIC_SHOP_BITE_LOGO_URL, e.g. the
14
- // lead demos) wins over the files in public/; the dark presets use dark/.
13
+ // A logo URL from runtime config (NUXT_PUBLIC_SHOP_BITE_LOGO_URL, e.g. one
14
+ // image serving several shops) wins over the files in public/; the dark presets use dark/.
15
15
  const logoSrc = computed(
16
16
  () =>
17
17
  (shopBite as { logoUrl?: string }).logoUrl ||
@@ -35,11 +35,6 @@ const diets = computed(() =>
35
35
  diet === "vegan" ? "Vegan" : "Vegetarisch",
36
36
  ),
37
37
  );
38
- // Allergen and additive codes (#485); the legend below the list explains
39
- // them, screen readers get the names.
40
- const foodLabels = computed(() => getFoodLabels(sortedProperties.value));
41
- const foodCodes = computed(() => foodLabelCodes(foodLabels.value));
42
- const foodText = computed(() => foodLabelText(foodLabels.value));
43
38
  // Read before the name; the strip with the number is aria-hidden. Built in
44
39
  // script: a trailing space in the template would be condensed away.
45
40
  // The strip has a fixed width so the cards line up (#441); menu numbers
@@ -156,14 +151,6 @@ function onLinkClick(event: MouseEvent) {
156
151
  <p v-if="ingredients" class="text-sm leading-snug text-sb-ink-muted">
157
152
  {{ ingredients }}
158
153
  </p>
159
- <p
160
- v-if="foodCodes.length"
161
- class="text-xs tracking-wide text-sb-ink-muted tabular-nums"
162
- data-testid="food-codes"
163
- >
164
- <span aria-hidden="true">{{ foodCodes.join(", ") }}</span
165
- ><span class="sr-only">{{ foodText }}</span>
166
- </p>
167
154
  <div class="mt-auto flex items-center justify-between pt-1.5">
168
155
  <span class="text-base font-bold tabular-nums">{{ price }}</span>
169
156
  <span
@@ -1,10 +1,19 @@
1
1
  <script setup lang="ts">
2
2
  import type { Schemas } from "#shopware";
3
+ import {
4
+ PopoverContent,
5
+ PopoverPortal,
6
+ PopoverRoot,
7
+ PopoverTrigger,
8
+ } from "reka-ui";
3
9
 
4
10
  /**
5
- * Allergens and additives in the product sheet (#485). Without the
6
- * restaurant's confirmation an empty list is "not entered yet", so the
7
- * sheet never claims "free of allergens" then and points to the phone.
11
+ * Allergens and additives of a dish behind an info button in the sheet's
12
+ * toolbar (#500): reachable before ordering, shown only to guests who look
13
+ * for them. Without the restaurant's confirmation an empty list is "not
14
+ * entered yet", so it never claims "free of allergens" then and points to
15
+ * the phone (#485). The content stays inside the sheet (no teleport), so
16
+ * the dialog's focus trap keeps working.
8
17
  */
9
18
  const props = defineProps<{ product: Schemas["Product"] }>();
10
19
 
@@ -19,21 +28,39 @@ const text = computed(() => foodLabelText(labels.value));
19
28
  </script>
20
29
 
21
30
  <template>
22
- <p class="text-sm text-sb-ink-muted" data-testid="food-labels">
23
- <template v-if="text">{{ text }}</template>
24
- <template v-else-if="checked"
25
- >Ohne kennzeichnungspflichtige Allergene und Zusatzstoffe.</template
26
- >
27
- <template v-else>
28
- Angaben zu Allergenen und Zusatzstoffen erhalten Sie im
29
- Restaurant<template v-if="site.telephone"
30
- >:
31
- <a
32
- :href="toTelHref(site.telephone)"
33
- class="font-semibold text-sb-ink underline underline-offset-4"
34
- >{{ site.telephone }}</a
35
- ></template
36
- >.
37
- </template>
38
- </p>
31
+ <PopoverRoot>
32
+ <PopoverTrigger as-child>
33
+ <SbIconButton label="Allergene und Zusatzstoffe">
34
+ <SbIcon name="info" />
35
+ </SbIconButton>
36
+ </PopoverTrigger>
37
+ <PopoverPortal disabled>
38
+ <PopoverContent
39
+ side="bottom"
40
+ align="end"
41
+ :side-offset="6"
42
+ :collision-padding="16"
43
+ class="z-50 w-72 max-w-[calc(100vw-32px)] rounded-sb-card border border-sb-line bg-sb-surface p-4 text-sm text-sb-ink shadow-lg focus-visible:outline-none"
44
+ data-testid="food-labels"
45
+ >
46
+ <p class="mb-1 font-semibold">Allergene und Zusatzstoffe</p>
47
+ <p class="text-sb-ink-muted">
48
+ <template v-if="text">{{ text }}</template>
49
+ <template v-else-if="checked"
50
+ >Ohne kennzeichnungspflichtige Allergene und Zusatzstoffe.</template
51
+ >
52
+ <template v-else>
53
+ Angaben erhalten Sie im Restaurant<template v-if="site.telephone"
54
+ >:
55
+ <a
56
+ :href="toTelHref(site.telephone)"
57
+ class="font-semibold text-sb-ink underline underline-offset-4"
58
+ >{{ site.telephone }}</a
59
+ ></template
60
+ >.
61
+ </template>
62
+ </p>
63
+ </PopoverContent>
64
+ </PopoverPortal>
65
+ </PopoverRoot>
39
66
  </template>
@@ -89,11 +89,11 @@ function onVariantSelected(variant: Schemas["Product"]) {
89
89
  >{{ diets.join(" · ") }}{{ description ? " · " : "" }}</span
90
90
  >{{ description }}
91
91
  </DialogDescription>
92
- <ProductFoodLabels v-if="product" :product="product" />
93
92
  </div>
94
93
  </div>
95
94
  </template>
96
95
  <template #actions>
96
+ <ProductFoodLabels v-if="product" :product="product" />
97
97
  <WishlistSaveButton :selection="selection" :name="label" />
98
98
  <SbIconButton
99
99
  :label="canShare ? 'Teilen' : 'Link kopieren'"
@@ -16,7 +16,8 @@ type IconName =
16
16
  | "phone"
17
17
  | "heart"
18
18
  | "bag"
19
- | "chevron-up";
19
+ | "chevron-up"
20
+ | "info";
20
21
 
21
22
  withDefaults(
22
23
  defineProps<{ name: IconName; size?: number; filled?: boolean }>(),
@@ -38,6 +39,7 @@ const PATHS: Record<IconName, string[]> = {
38
39
  "M16 10a4 4 0 0 1-8 0",
39
40
  ],
40
41
  "chevron-up": ["m18 15-6-6-6 6"],
42
+ info: ["M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20z", "M12 16v-4", "M12 8h.01"],
41
43
  heart: [
42
44
  "M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z",
43
45
  ],
@@ -1,27 +1,48 @@
1
1
  import { useShopwareContext } from "#imports";
2
2
  import type { Ref } from "vue";
3
+ import type { Schemas } from "#shopware";
3
4
  import { setTime } from "~/utils/time";
4
5
 
5
6
  export type ServiceInterval = { start: Date; end: Date };
6
7
 
8
+ export const BUSINESS_HOURS_KEY = "business-hours";
9
+
10
+ type ApiClient = ReturnType<typeof useShopwareContext>["apiClient"];
11
+
12
+ /**
13
+ * Weekly opening hours: from the server's cache (`/api/shopbite/business-
14
+ * hours`, `cacheTtl.businessHours`) for server-side rendering, from
15
+ * Shopware in the browser, where app.vue reloads them after hydration
16
+ * (useLiveShopData). Retried in the browser only: on the server a retry
17
+ * would delay the page (#355).
18
+ */
19
+ export async function loadBusinessHours(
20
+ apiClient: ApiClient,
21
+ fromServerCache: boolean,
22
+ retryDelays: readonly number[] = OPENING_HOURS_RETRY_DELAYS,
23
+ ): Promise<Schemas["BusinessHourStruct"]["businessHours"]> {
24
+ if (fromServerCache) {
25
+ const cached = await $fetch<Schemas["BusinessHourStruct"]>(
26
+ "/api/shopbite/business-hours",
27
+ );
28
+ return cached.businessHours;
29
+ }
30
+ const response = await withRetries(
31
+ () =>
32
+ apiClient.invoke(
33
+ "shopbite.business-hour.get get /shopbite/business-hour",
34
+ ),
35
+ retryDelays,
36
+ );
37
+ return response.data.businessHours;
38
+ }
39
+
7
40
  export function useBusinessHours() {
8
41
  const { apiClient } = useShopwareContext();
9
42
 
10
43
  const { data, pending, status, refresh } = useAsyncData(
11
- "business-hours",
12
- async () => {
13
- // Retried in the browser only: on the server a retry would delay the
14
- // page, and app.vue loads the data again after mounting (#355).
15
- const response = await withRetries(
16
- () =>
17
- apiClient.invoke(
18
- "shopbite.business-hour.get get /shopbite/business-hour",
19
- ),
20
- import.meta.client ? OPENING_HOURS_RETRY_DELAYS : [],
21
- );
22
-
23
- return response.data.businessHours;
24
- },
44
+ BUSINESS_HOURS_KEY,
45
+ () => loadBusinessHours(apiClient, import.meta.server),
25
46
  { immediate: false },
26
47
  );
27
48
 
@@ -1,20 +1,40 @@
1
1
  import { useShopwareContext } from "#imports";
2
+ import type { Schemas } from "#shopware";
3
+
4
+ export const HOLIDAYS_KEY = "holidays";
5
+
6
+ type ApiClient = ReturnType<typeof useShopwareContext>["apiClient"];
7
+
8
+ /**
9
+ * Closing days: from the server's cache (`/api/shopbite/holidays`,
10
+ * `cacheTtl.holidays`) for server-side rendering, from Shopware in the
11
+ * browser, where app.vue reloads them after hydration (useLiveShopData).
12
+ * Retried in the browser only (#355).
13
+ */
14
+ export async function loadHolidays(
15
+ apiClient: ApiClient,
16
+ fromServerCache: boolean,
17
+ retryDelays: readonly number[] = OPENING_HOURS_RETRY_DELAYS,
18
+ ): Promise<Schemas["HolidayStruct"]["holidays"]> {
19
+ if (fromServerCache) {
20
+ const cached = await $fetch<Schemas["HolidayStruct"]>(
21
+ "/api/shopbite/holidays",
22
+ );
23
+ return cached.holidays;
24
+ }
25
+ const response = await withRetries(
26
+ () => apiClient.invoke("shopbite.holiday.get get /shopbite/holiday"),
27
+ retryDelays,
28
+ );
29
+ return response.data.holidays;
30
+ }
2
31
 
3
32
  export function useHolidays() {
4
33
  const { apiClient } = useShopwareContext();
5
34
 
6
35
  const { data, pending, status, refresh } = useAsyncData(
7
- "holidays",
8
- async () => {
9
- // Retried in the browser only: on the server a retry would delay the
10
- // page, and app.vue loads the data again after mounting (#355).
11
- const response = await withRetries(
12
- () => apiClient.invoke("shopbite.holiday.get get /shopbite/holiday"),
13
- import.meta.client ? OPENING_HOURS_RETRY_DELAYS : [],
14
- );
15
-
16
- return response.data.holidays;
17
- },
36
+ HOLIDAYS_KEY,
37
+ () => loadHolidays(apiClient, import.meta.server),
18
38
  { immediate: false },
19
39
  );
20
40
 
@@ -1,42 +1,14 @@
1
+ import type { Schemas } from "#shopware";
2
+
1
3
  /**
2
4
  * The menu sections of the home page (#388, #444): the children of the menu
3
- * root (useMenuRootId: env, plugin configuration, navigation root) with their photo
5
+ * root (env, plugin configuration, navigation root; resolved on the server) with their photo
4
6
  * (`category.media`). Shared by the tiles and the word list of the presets.
5
7
  */
6
8
  export async function useHomeMenuCategories() {
7
- const { apiClient } = useShopwareContext();
8
- const menuRootId = useMenuRootId();
9
-
10
- const { data: categories } = await useAsyncData(
11
- "home-menu-categories",
12
- async () => {
13
- const response = await apiClient.invoke(
14
- "readNavigation post /navigation/{activeId}/{rootId}",
15
- {
16
- body: {
17
- depth: 1,
18
- // Sent as a POST body so the projection is honoured (#312).
19
- includes: {
20
- category: [
21
- "id",
22
- "name",
23
- "translated",
24
- "seoUrl",
25
- "customFields",
26
- "media",
27
- ],
28
- media: ["url", "thumbnails", "metaData"],
29
- media_thumbnail: ["url", "width"],
30
- },
31
- },
32
- pathParams: {
33
- activeId: "main-navigation",
34
- rootId: await menuRootId(),
35
- },
36
- },
37
- );
38
- return response.data;
39
- },
9
+ // Cached on the server with the other navigations (server/api/navigation).
10
+ const { data: categories } = await useAsyncData("home-menu-categories", () =>
11
+ $fetch<Schemas["Category"][]>("/api/navigation/home"),
40
12
  );
41
13
 
42
14
  return { categories };
@@ -0,0 +1,17 @@
1
+ import { BUSINESS_HOURS_KEY } from "./useBusinessHours";
2
+ import { HOLIDAYS_KEY } from "./useHolidays";
3
+ import { SHOPBITE_CONFIG_KEY } from "./useShopBiteConfig";
4
+
5
+ /**
6
+ * The checkout switch, opening hours and closing days are rendered from the
7
+ * server's caches; after mounting the browser loads them from Shopware once
8
+ * (app.vue), so the store status, the delivery time choice and every
9
+ * checkout button act on current data. `refreshNuxtData` waits for the end
10
+ * of hydration: a `refresh()` during hydration returns the server's payload
11
+ * without a request.
12
+ */
13
+ export function useLiveShopData() {
14
+ onMounted(() =>
15
+ refreshNuxtData([SHOPBITE_CONFIG_KEY, BUSINESS_HOURS_KEY, HOLIDAYS_KEY]),
16
+ );
17
+ }