@shopbite-de/storefront 1.23.3 → 1.24.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 (153) hide show
  1. package/.env.example +19 -0
  2. package/.github/workflows/build.yaml +1 -1
  3. package/.github/workflows/ci.yaml +6 -3
  4. package/CLAUDE.md +41 -3
  5. package/README.md +139 -40
  6. package/api-gen.config.json +9 -0
  7. package/api-types/storeApiSchema.shopbite.overrides.json +35 -0
  8. package/api-types/storeApiTypes.d.ts +95 -81
  9. package/app/app.vue +37 -53
  10. package/app/assets/css/main.css +20 -4
  11. package/app/components/Address/Fields.vue +2 -21
  12. package/app/components/AnimatedSection.vue +9 -4
  13. package/app/components/BottomNavi.vue +9 -2
  14. package/app/components/Cart/Item.vue +21 -10
  15. package/app/components/Category/Header.vue +9 -3
  16. package/app/components/Category/Listing.vue +51 -42
  17. package/app/components/Checkout/PaymentAndDelivery.vue +19 -3
  18. package/app/components/Checkout/Summary.vue +65 -1
  19. package/app/components/Cta.vue +4 -2
  20. package/app/components/Food/MarqueeItem.vue +20 -8
  21. package/app/components/Footer/Contact.vue +78 -0
  22. package/app/components/Footer/StoreStatus.vue +30 -0
  23. package/app/components/Footer.vue +2 -1
  24. package/app/components/Header/Body.vue +1 -1
  25. package/app/components/Header/Right.vue +27 -13
  26. package/app/components/Header/Title.vue +1 -0
  27. package/app/components/Header.vue +5 -15
  28. package/app/components/Hero.vue +45 -2
  29. package/app/components/ImageGallery.vue +11 -5
  30. package/app/components/Product/Card.vue +9 -3
  31. package/app/components/Product/CardFooter.vue +22 -12
  32. package/app/components/User/RegistrationForm.vue +0 -1
  33. package/app/components/Wishlist.vue +2 -15
  34. package/app/composables/useAddToCart.ts +13 -13
  35. package/app/composables/useAddressAutocomplete.ts +12 -19
  36. package/app/composables/useAddressSuggestionArea.ts +16 -0
  37. package/app/composables/useAddressValidation.ts +3 -19
  38. package/app/composables/useCartMutations.ts +168 -0
  39. package/app/composables/{useCategory.ts → useCategoryById.ts} +1 -1
  40. package/app/composables/useCategorySeo.ts +22 -25
  41. package/app/composables/useCheckoutMethodGuard.ts +201 -0
  42. package/app/composables/useMatomo.ts +25 -0
  43. package/app/composables/useMatomoConfig.ts +12 -0
  44. package/app/composables/useMenuSectionSchema.ts +55 -0
  45. package/app/composables/useNavigation.ts +12 -9
  46. package/app/composables/usePageSeo.ts +50 -0
  47. package/app/composables/useRestaurantSchema.ts +64 -0
  48. package/app/composables/useScrollAnimation.ts +39 -8
  49. package/app/composables/useSearchTracking.ts +33 -0
  50. package/app/composables/useSeoUrlRoute.ts +58 -0
  51. package/app/composables/useSortingSelection.ts +28 -0
  52. package/app/composables/useStoreStatus.ts +48 -0
  53. package/app/composables/useTrackEvent.ts +29 -23
  54. package/app/pages/[...all].vue +4 -4
  55. package/app/pages/account/recover/password/index.vue +1 -0
  56. package/app/pages/anmelden.vue +4 -0
  57. package/app/pages/bestellung/[id]/erfolg.vue +1 -5
  58. package/app/pages/bestellung/[id]/fehler.vue +2 -2
  59. package/app/pages/bestellung/[id]/index.vue +9 -3
  60. package/app/pages/bestellung/bestaetigen.vue +1 -5
  61. package/app/pages/bestellung/warenkorb.vue +1 -5
  62. package/app/pages/bestellung/zahlung-versand.vue +1 -5
  63. package/app/pages/c/[...all].vue +2 -35
  64. package/app/pages/index.vue +25 -13
  65. package/app/pages/kontakt.vue +4 -0
  66. package/app/pages/konto/adressen.vue +4 -0
  67. package/app/pages/konto/bestellung/[id].vue +4 -0
  68. package/app/pages/konto/bestellungen.vue +4 -0
  69. package/app/pages/konto/index.vue +4 -0
  70. package/app/pages/konto/profil.vue +4 -0
  71. package/app/pages/maintenance.vue +6 -0
  72. package/app/pages/merkliste.vue +1 -7
  73. package/app/pages/passwort-vergessen.vue +1 -0
  74. package/app/pages/registrierung/bestaetigen.vue +4 -0
  75. package/app/pages/registrierung/index.vue +4 -0
  76. package/app/pages/speisekarte/[...all].vue +2 -36
  77. package/app/pages/suche.vue +24 -21
  78. package/app/plugins/matomo.ts +35 -0
  79. package/app/utils/hydrateWhenVisible.ts +20 -0
  80. package/app/utils/media.ts +33 -0
  81. package/app/utils/openingHours.ts +67 -0
  82. package/app/utils/schema.ts +235 -0
  83. package/app/utils/seo.ts +56 -0
  84. package/app/utils/seoPath.ts +57 -0
  85. package/content/index.yml +10 -9
  86. package/content.config.ts +3 -0
  87. package/docs/notes/2026-07-05-issue-259-matomo-broken.md +7 -0
  88. package/docs/notes/2026-09-08-issue-240-shipping-method-blocked.md +83 -0
  89. package/docs/notes/2026-09-08-issue-241-cart-lock-conflicts.md +63 -0
  90. package/docs/notes/2026-09-08-issue-244-category-url-trailing-slash.md +65 -0
  91. package/docs/notes/2026-09-08-issue-276-payment-method-blocked.md +39 -0
  92. package/docs/notes/2026-09-08-issue-277-typecheck.md +99 -0
  93. package/docs/notes/2026-09-10-issue-250-animated-section.md +23 -0
  94. package/docs/notes/2026-09-10-issue-251-shop-data-in-base-layer.md +30 -0
  95. package/docs/notes/2026-09-10-issue-272-restaurant-schema.md +27 -0
  96. package/docs/notes/2026-09-10-issue-273-performance-media.md +64 -0
  97. package/docs/notes/2026-09-10-issue-274-seo-basics.md +49 -0
  98. package/docs/notes/2026-09-10-issue-275-accessibility.md +46 -0
  99. package/docs/notes/2026-09-10-issue-290-footer-nap.md +28 -0
  100. package/docs/notes/2026-09-10-issue-291-seo-url-trailing-slash.md +24 -0
  101. package/docs/notes/2026-09-10-issue-294-matomo-without-config.md +33 -0
  102. package/docs/notes/2026-09-10-issue-295-search-hydration-mismatch.md +25 -0
  103. package/docs/notes/2026-09-10-issue-296-track-direct-search.md +19 -0
  104. package/docs/notes/2026-09-10-issue-312-store-api-criteria-post.md +64 -0
  105. package/docs/notes/2026-09-10-issue-313-wishlist-scoped-tailwind.md +29 -0
  106. package/docs/notes/2026-09-10-issue-314-mobile-js-cost.md +119 -0
  107. package/node.dockerfile +5 -2
  108. package/nuxt.config.ts +74 -15
  109. package/package.json +5 -3
  110. package/patches/@shopware__nuxt-module@1.5.1.patch +32 -0
  111. package/pnpm-workspace.yaml +2 -0
  112. package/public/hero-poster.webp +0 -0
  113. package/server/api/__sitemap__/urls.get.ts +49 -0
  114. package/server/api/category/[categoryId].get.ts +20 -9
  115. package/server/api/content/home.get.ts +14 -0
  116. package/server/api/content/page.get.ts +22 -0
  117. package/server/api/listing/[categoryId].get.ts +12 -18
  118. package/server/api/product/[productId]/cross-selling.get.ts +3 -9
  119. package/server/api/product/[productId].get.ts +4 -8
  120. package/server/plugins/site-url.ts +13 -0
  121. package/server/plugins/sitemap-trailing-slash.ts +26 -0
  122. package/server/utils/sitemap.ts +60 -0
  123. package/server/utils/storeApi.ts +34 -0
  124. package/shopware.d.ts +35 -11
  125. package/test/nuxt/AddressFields.test.ts +2 -73
  126. package/test/nuxt/AnimatedSection.test.ts +67 -0
  127. package/test/nuxt/CartItem.test.ts +95 -0
  128. package/test/nuxt/FooterContact.test.ts +102 -0
  129. package/test/nuxt/FooterStoreStatus.test.ts +48 -0
  130. package/test/nuxt/HeaderRight.test.ts +14 -10
  131. package/test/nuxt/Hero.test.ts +68 -0
  132. package/test/nuxt/PaymentAndDelivery.test.ts +67 -8
  133. package/test/nuxt/RegistrationForm.test.ts +3 -0
  134. package/test/nuxt/useAddToCart.test.ts +34 -1
  135. package/test/nuxt/useAddressAutocomplete.test.ts +2 -38
  136. package/test/nuxt/useAddressSuggestionArea.test.ts +27 -0
  137. package/test/nuxt/useBusinessHours.test.ts +1 -1
  138. package/test/nuxt/useCartMutations.test.ts +225 -0
  139. package/test/nuxt/useCheckoutMethodGuard.test.ts +386 -0
  140. package/test/nuxt/useScrollAnimation.test.ts +55 -49
  141. package/test/nuxt/useSearchTracking.test.ts +71 -0
  142. package/test/nuxt/useSeoUrlRoute.test.ts +93 -0
  143. package/test/nuxt/useStoreStatus.test.ts +77 -0
  144. package/test/nuxt/useTrackEvent.test.ts +112 -0
  145. package/test/unit/media.spec.ts +49 -0
  146. package/test/unit/openingHours.spec.ts +59 -0
  147. package/test/unit/schema.spec.ts +243 -0
  148. package/test/unit/seo.spec.ts +107 -0
  149. package/test/unit/seoPath.spec.ts +116 -0
  150. package/test/unit/sitemap.spec.ts +88 -0
  151. package/test/unit/useCategorySeo.spec.ts +40 -30
  152. package/test/unit/useSortingSelection.spec.ts +39 -0
  153. package/app/composables/useValidCitiesForDelivery.ts +0 -12
@@ -0,0 +1,119 @@
1
+ # Issue #314: Mobile JavaScript cost
2
+
3
+ As of 2026-09-10, branch `fix/314-mobile-js-cost`.
4
+
5
+ ## Measurement setup
6
+
7
+ Production build, La Fattoria Store API, Lighthouse 12.8.2 mobile
8
+ (simulated throttling, 4× CPU) behind the h2/gzip proxy from
9
+ `docs/notes/2026-09-10-issue-273-performance-media.md`; two runs per page,
10
+ same machine. Chunk attribution comes from the client manifest that Nuxt
11
+ inlines into `.output/server/chunks/virtual/precomputed.mjs` (the preload
12
+ set of the entry is what the head lists as `modulepreload`).
13
+
14
+ ## Findings on the baseline (main)
15
+
16
+ - The entry preloads 102 scripts (302 KB gzipped); 54 of them are below
17
+ 1 KB (reka-ui and Nuxt UI internals shared by several pages).
18
+ - `SalesChannelSwitch` was rendered on every page although the feature is
19
+ off by default: it pulled `USelectMenu` (Combobox virtualizer, 25 KB
20
+ gzipped) into the entry and fired a `/shopbite/multi-channel-group`
21
+ request per page.
22
+ - `useMatomo` (the @nuxt/scripts registry composable, 10 KB gzipped) sat in
23
+ the entry through `useTrackEvent`, also for shops without Matomo.
24
+ - `Header.vue` rendered a login `USlideover` that nothing opened.
25
+ - `NuxtLink` prefetched the chunks of every link in view: ~20 chunks and a
26
+ page stylesheet (72 KB) during the initial load of the home page.
27
+ - On the category page the cart drawer, the mobile filter drawer (both
28
+ vaul) and one `UCollapsible` per card were mounted with the page; the
29
+ drawer chunk and the collapsible chunk each cost ~400 ms of scripting
30
+ (mostly forced layout on a 1,200-element page).
31
+ - Client-side navigation to a content page (`/agb`) or back to `/` loads
32
+ the SQLite WASM build (865 KB) plus the collection dump, because
33
+ `queryCollection()` in the browser prefers WASM whenever
34
+ `window.WebAssembly` exists.
35
+ - `Style & Layout` (~1.1 s on the home page, 313 DOM elements) is the
36
+ first render of the 253 KB stylesheet; not JavaScript, not part of this
37
+ issue.
38
+ - Sentry ships no client code (no `sentry.client.config.ts`).
39
+
40
+ ## Changes
41
+
42
+ 1. `LazySalesChannelSwitch v-if="multiChannel"` in `Header.vue` and
43
+ `Header/Body.vue`; the dead login slideover is removed.
44
+ 2. `plugins/matomo.ts` imports `useMatomo` after `onNuxtReady`;
45
+ `useTrackEvent` pushes to Matomo's `_paq` queue directly (matomo.js
46
+ replays it), gated by the new `useMatomoConfig()`.
47
+ 3. `hydrateWhenVisible()` (`app/utils`): keeps the server-rendered markup of
48
+ a component and hydrates it when it comes within 600 px of the viewport,
49
+ without turning it into a separate chunk. Used for the product cards in
50
+ `Category/Listing.vue` and `pages/suche.vue` and for the footer in
51
+ `app.vue`. The margin exceeds the reveal margin of `AnimatedSection`
52
+ (100 px), so the scroll animation still runs.
53
+ 4. Cart drawer (`Header/Right.vue`), mobile filter drawer
54
+ (`Category/Listing.vue`) and the product options collapsible
55
+ (`Product/CardFooter.vue`) are created on first use (`v-if` + `nextTick`
56
+ before opening); the `ClientOnly` wrappers they needed are gone.
57
+ 5. `experimental.defaults.nuxtLink.prefetchOn = { visibility: false,
58
+ interaction: true }`: route chunks load on hover/touch.
59
+ 6. `server/api/content/home.get.ts` and `page.get.ts` run the content
60
+ queries on the server (`@nuxt/content/server`); `pages/index.vue` and
61
+ `pages/[...all].vue` fetch them.
62
+ 7. Rolldown `codeSplitting.groups` (`nuxt.config.ts`, `vite.build`):
63
+ framework and UI modules shared by at least two chunks form two chunks
64
+ instead of ~60 tiny ones.
65
+
66
+ ## Results (Lighthouse mobile, two runs each)
67
+
68
+ | Page | Metric | Baseline | After |
69
+ | --- | --- | --- | --- |
70
+ | `/` | TBT | 330–400 ms | 150–170 ms |
71
+ | `/` | Script evaluation | 705–811 ms | 600–630 ms |
72
+ | `/` | Script requests (transfer) | 135 (394 KB) | 34–35 (335 KB) |
73
+ | `/` | Main thread | 2.5–2.6 s | 2.1–2.2 s |
74
+ | `/c/Pizza/` | TBT | 570–590 ms | 300–340 ms |
75
+ | `/c/Pizza/` | Script evaluation | 1.5–1.6 s | 1.1–1.2 s |
76
+ | `/c/Pizza/` | Script requests (transfer) | 133 (394 KB) | 35 (321 KB) |
77
+ | `/c/Pizza/` | Main thread | 4.0 s | 2.9–3.1 s |
78
+
79
+ Three runs of the final build (two of the chunk-group step, one of the
80
+ final commit); the category numbers are for the 29-product "Pizza"
81
+ category, the 100-product case scales with the same mechanism (cards
82
+ hydrate on scroll).
83
+
84
+ Intermediate steps: changes 1–3 brought the home page to TBT 280–290 ms
85
+ / 650–680 ms script evaluation and the category page to 420–440 ms /
86
+ 1.25–1.3 s; changes 4–5 to 190–260 ms / 570–600 ms and 390–480 ms /
87
+ 1.14–1.2 s; the chunk groups (7) cut the requests from 116 to 34 and
88
+ took TBT to 170 ms / 340 ms. The entry's preload set went from 102
89
+ scripts (302 KB gzipped) to 25 (301 KB): the shared `ui` chunk carries
90
+ UI code that not every page needs, but the bytes are the same and the
91
+ module overhead is gone.
92
+
93
+ FCP (3.0–3.3 s) and LCP are unchanged: they are the local headless
94
+ first-paint artefact described in the #273 note and the stylesheet
95
+ (`Style & Layout` ~1 s on 311 DOM elements), not JavaScript.
96
+
97
+ ## Not done
98
+
99
+ - `Style & Layout` ~1 s on every page comes from the 253 KB Tailwind /
100
+ Nuxt UI stylesheet; a CSS topic of its own.
101
+ - `UHeader` imports `UModal`, `UDrawer` and `USlideover` statically
102
+ (Nuxt UI), so vaul stays in the entry even though the drawers are
103
+ created on demand.
104
+ - The wishlist button on the product card has only a tooltip, no
105
+ `aria-label` (noticed while writing the checks).
106
+ - `nuxt-vitalizer`'s `disablePreloadLinks` was not tried: with 25
107
+ preloads left, the trade (a later start per chunk) has little to gain.
108
+
109
+ ## Verification
110
+
111
+ - Playwright (mobile viewport): first and middle product card open their
112
+ options after scrolling, the wishlist button of the last card updates the
113
+ header count, the filter drawer and the cart drawer open, the footer's
114
+ colour mode button works, no console errors; client-side navigation to
115
+ `/agb` and back to `/` no longer requests the WASM build or a SQL dump.
116
+ - Matomo with `NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_*` set: the registry
117
+ chunk loads after `onNuxtReady`, `matomo.js` is requested and `_paq`
118
+ holds the page view.
119
+ - Unit tests, Prettier, ESLint, typecheck and build pass.
package/node.dockerfile CHANGED
@@ -14,8 +14,11 @@ WORKDIR /app
14
14
 
15
15
  RUN corepack enable && corepack prepare pnpm@${PNPM_VERSION} --activate
16
16
 
17
- # Copy manifests first so dependency layer is cached independently from source changes
18
- COPY package.json pnpm-lock.yaml .npmrc ./
17
+ # Copy manifests first so dependency layer is cached independently from source changes.
18
+ # pnpm-workspace.yaml (allowBuilds, patchedDependencies) and patches/ are part of the
19
+ # lockfile contract; without them `--frozen-lockfile` fails.
20
+ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
21
+ COPY patches ./patches
19
22
  RUN pnpm install --frozen-lockfile --prefer-offline
20
23
 
21
24
  COPY . .
package/nuxt.config.ts CHANGED
@@ -20,7 +20,7 @@ export default defineNuxtConfig({
20
20
  },
21
21
  {
22
22
  property: "og:title",
23
- content: storeDescription,
23
+ content: storeName,
24
24
  },
25
25
  {
26
26
  property: "og:description",
@@ -40,6 +40,14 @@ export default defineNuxtConfig({
40
40
  "/account/recover/password",
41
41
  ],
42
42
  },
43
+ sitemap: {
44
+ // File-based pages and route rules (ssr/swr/redirect) are checkout and
45
+ // account flows; indexable URLs come from the home page, content pages
46
+ // and the Store API source.
47
+ excludeAppSources: ["nuxt:pages", "nuxt:route-rules"],
48
+ urls: ["/"],
49
+ sources: ["/api/__sitemap__/urls"],
50
+ },
43
51
 
44
52
  runtimeConfig: {
45
53
  shopware: {
@@ -60,6 +68,11 @@ export default defineNuxtConfig({
60
68
  },
61
69
  menuCategoryId: "",
62
70
  searchFallbackCategoryId: "",
71
+ // Optional Geoapify bounding box "lon1,lat1,lon2,lat2" that narrows
72
+ // the address suggestions in the checkout (empty = no filter, #251).
73
+ addressAutocomplete: {
74
+ boundingBox: "",
75
+ },
63
76
  feature: {
64
77
  multiChannel: false,
65
78
  secureKey: "",
@@ -70,12 +83,31 @@ export default defineNuxtConfig({
70
83
  name: storeName,
71
84
  description: storeDescription,
72
85
  countryId: "",
86
+ // `%s` = page title, `%siteName` = site.name; the home page renders
87
+ // its title without the template.
88
+ titleTemplate: "%s | %siteName – Online bestellen",
89
+ // Share preview for pages without their own image (path or URL).
90
+ ogImage: "/card.png",
91
+ // Used in the default home page title and description.
92
+ cuisine: "",
93
+ // Shown in the footer (NAP for local SEO, #290) and in the Restaurant
94
+ // schema (#272); empty values are left out.
95
+ address: {
96
+ street: "",
97
+ postalCode: "",
98
+ city: "",
99
+ country: "DE",
100
+ },
101
+ telephone: "",
102
+ googleBusinessProfileUrl: "",
103
+ // Restaurant schema only, e.g. "€€" (#272).
104
+ priceRange: "",
73
105
  },
74
106
  storeUrl: "",
75
- // Matomo config for the @nuxt/scripts registry. Declared here (not as
76
- // registry options) so the values stay runtime-overridable via
77
- // NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_* env vars: registry options are
78
- // inlined into the build and would shadow the runtime config (#259).
107
+ // Matomo config, runtime-overridable via NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_*
108
+ // env vars. Never set these as registry options: those are inlined into
109
+ // the build and shadow the runtime config (#259). Matomo only loads when
110
+ // both values are set (app/plugins/matomo.ts, #294).
79
111
  scripts: {
80
112
  matomoAnalytics: {
81
113
  matomoUrl: "",
@@ -109,6 +141,8 @@ export default defineNuxtConfig({
109
141
  modules: [
110
142
  "@shopware/nuxt-module",
111
143
  "@nuxt/image",
144
+ // must be loaded before @nuxt/content for the content integration
145
+ "@nuxtjs/sitemap",
112
146
  "@nuxt/content",
113
147
  "@nuxtjs/robots",
114
148
  "@vite-pwa/nuxt",
@@ -206,6 +240,32 @@ export default defineNuxtConfig({
206
240
  compatibilityDate: "2025-07-15",
207
241
 
208
242
  vite: {
243
+ build: {
244
+ // Vite 8 bundles with Rolldown; `rollupOptions` would drop this key.
245
+ rolldownOptions: {
246
+ output: {
247
+ // Rolldown code splitting: the framework and UI libraries used by
248
+ // more than one chunk go into two shared chunks instead of ~60
249
+ // tiny ones, which halves the module preloads of every page (#314).
250
+ codeSplitting: {
251
+ groups: [
252
+ {
253
+ name: "framework",
254
+ test: /node_modules\/(\.pnpm\/)?(vue|@vue\+|@vue\/|vue-router|unhead|@unhead|nuxt@|hookable|ofetch|ufo|defu|h3|devalue|klona|destr|cookie-es|radix3|rou3|unctx|pinia)[@/]/,
255
+ minShareCount: 2,
256
+ priority: 20,
257
+ },
258
+ {
259
+ name: "ui",
260
+ test: /node_modules\/(\.pnpm\/)?(reka-ui|@nuxt\+ui|@nuxt\/ui|tailwind-variants|tailwind-merge|@floating-ui|@vueuse|vaul-vue|@internationalized|@tanstack|@nuxt\+icon|@nuxt\/icon|@iconify)[@/]/,
261
+ minShareCount: 2,
262
+ priority: 10,
263
+ },
264
+ ],
265
+ },
266
+ },
267
+ },
268
+ },
209
269
  optimizeDeps: {
210
270
  include: [
211
271
  "@vue/devtools-core",
@@ -224,11 +284,20 @@ export default defineNuxtConfig({
224
284
  asyncContext: true,
225
285
  payloadExtraction: true,
226
286
  watcher: "parcel",
287
+ defaults: {
288
+ nuxtLink: {
289
+ // Prefetch route chunks on hover/touch instead of for every link in
290
+ // view: the header alone pulled ~20 chunks and a page stylesheet
291
+ // during the initial load (#314).
292
+ prefetchOn: { visibility: false, interaction: true },
293
+ },
294
+ },
227
295
  },
228
296
  $development: {
229
297
  modules: [
230
298
  "@shopware/nuxt-module",
231
299
  "@nuxt/image",
300
+ "@nuxtjs/sitemap",
232
301
  "@nuxt/content",
233
302
  "@nuxtjs/robots",
234
303
  "@nuxt/ui",
@@ -238,14 +307,4 @@ export default defineNuxtConfig({
238
307
  "@nuxt/hints",
239
308
  ],
240
309
  },
241
- $production: {
242
- scripts: {
243
- registry: {
244
- // Only the trigger is set here so no option values get inlined into
245
- // the build; the actual config comes from runtimeConfig.public.scripts
246
- // above (env-overridable at runtime, see #259).
247
- matomoAnalytics: { trigger: "onNuxtReady" },
248
- },
249
- },
250
- },
251
310
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.23.3",
3
+ "version": "1.24.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -24,9 +24,10 @@
24
24
  "@iconify-json/simple-icons": "^1.2.95",
25
25
  "@nuxt/content": "3.16.0",
26
26
  "@nuxt/image": "^2.1.0",
27
- "@nuxt/scripts": "1.3.8",
27
+ "@nuxt/scripts": "1.3.9",
28
28
  "@nuxt/ui": "^4.11.1",
29
29
  "@nuxtjs/robots": "^6.2.0",
30
+ "@nuxtjs/sitemap": "^8.5.0",
30
31
  "@pinia/nuxt": "1.0.2",
31
32
  "@sentry/nuxt": "^10.73.0",
32
33
  "@shopware/api-client": "^1.5.1",
@@ -51,6 +52,7 @@
51
52
  "@nuxt/hints": "1.1.4",
52
53
  "@nuxt/test-utils": "^4.3.2",
53
54
  "@playwright/test": "^1.63.0",
55
+ "@types/js-cookie": "^3.0.6",
54
56
  "@types/node": "^26.5.0",
55
57
  "@typescript-eslint/eslint-plugin": "^8.70.0",
56
58
  "@typescript-eslint/parser": "^8.70.0",
@@ -87,6 +89,6 @@
87
89
  "generate-types": "shopware-api-gen generate --apiType=store",
88
90
  "load-schema": "pnpx @shopware/api-gen loadSchema --apiType=store",
89
91
  "lint:fix": "pnpm run prettier:fix && pnpm run eslint:fix",
90
- "typecheck": "pnpx nuxt typecheck --cwd=app"
92
+ "typecheck": "nuxt typecheck"
91
93
  }
92
94
  }
@@ -0,0 +1,32 @@
1
+ diff --git a/plugin.ts b/plugin.ts
2
+ index 5b9cdef440df1eb477ffea4d66180bc65b33835a..c23d08a8af61875b55e192d108d009bc5ddd7b07 100644
3
+ --- a/plugin.ts
4
+ +++ b/plugin.ts
5
+ @@ -14,7 +14,8 @@ import {
6
+ } from "#imports";
7
+ import type { ApiClient } from "#shopware";
8
+
9
+ -import type { ShopwareNuxtOptions } from "./src";
10
+ +import type { ShopwareNuxtOptions } from "./dist/index";
11
+ +import type { Plugin } from "#app";
12
+
13
+ declare module "#app" {
14
+ interface NuxtApp {
15
+ @@ -28,7 +29,10 @@ declare module "vue" {
16
+ }
17
+ }
18
+
19
+ -export default defineNuxtPlugin((NuxtApp) => {
20
+ +// Explicit type keeps Nuxt's generated NuxtApp augmentation from
21
+ +// recursively depending on this plugin's inferred return type.
22
+ +const shopwarePlugin: Plugin<{ shopwareApiClient: ApiClient }> =
23
+ + defineNuxtPlugin((NuxtApp) => {
24
+ const runtimeConfig = useRuntimeConfig();
25
+
26
+ const shopwareRuntimeConfigPublic = runtimeConfig.public
27
+ @@ -143,3 +147,5 @@ export default defineNuxtPlugin((NuxtApp) => {
28
+ },
29
+ };
30
+ });
31
+ +
32
+ +export default shopwarePlugin;
@@ -6,3 +6,5 @@ allowBuilds:
6
6
  sharp: true
7
7
  unrs-resolver: true
8
8
  vue-demi: true
9
+ patchedDependencies:
10
+ '@shopware/nuxt-module@1.5.1': patches/@shopware__nuxt-module@1.5.1.patch
Binary file
@@ -0,0 +1,49 @@
1
+ import type { components } from "~~/api-types/storeApiTypes";
2
+
3
+ type Schemas = components["schemas"];
4
+
5
+ const NAVIGATION_CRITERIA = {
6
+ depth: 10,
7
+ // flat list: in a tree, children would be dropped by the includes below
8
+ buildTree: false,
9
+ includes: {
10
+ category: ["seoUrl", "type", "updatedAt", "createdAt", "media"],
11
+ media: ["url"],
12
+ },
13
+ associations: {
14
+ media: {},
15
+ },
16
+ };
17
+
18
+ /**
19
+ * Dynamic sitemap source: categories of the main navigation and the menu
20
+ * category tree. Products follow once they have their own pages (#289).
21
+ */
22
+ export default defineSitemapEventHandler(async () => {
23
+ const { shopware, shopBite } = useRuntimeConfig().public;
24
+ const rootIds = new Set([
25
+ "main-navigation",
26
+ shopBite.menuCategoryId || "main-navigation",
27
+ ]);
28
+
29
+ const trees = await Promise.all(
30
+ [...rootIds].map((rootId) =>
31
+ $fetch<Schemas["Category"][]>(
32
+ `${shopware.endpoint}/navigation/main-navigation/${rootId}`,
33
+ {
34
+ method: "POST",
35
+ headers: {
36
+ "sw-access-key": shopware.accessToken,
37
+ "sw-include-seo-urls": "true",
38
+ },
39
+ body: NAVIGATION_CRITERIA,
40
+ },
41
+ ),
42
+ ),
43
+ );
44
+
45
+ return [
46
+ ...(shopBite.feature.contactForm ? ["/kontakt"] : []),
47
+ ...categoriesToSitemapUrls(trees.flat()),
48
+ ];
49
+ });
@@ -1,22 +1,33 @@
1
- import { encodeForQuery } from "@shopware/api-client/helpers";
2
1
  import type { components } from "~~/api-types/storeApiTypes";
3
2
  type Schemas = components["schemas"];
4
3
 
5
- const criteria = encodeForQuery({
4
+ // Everything the category header, useCategorySeo and the menu-section schema
5
+ // read; the projection only applies with a POST body (#312).
6
+ const criteria = {
6
7
  includes: {
7
- category: ["name", "translated", "seoUrl", "externalLink", "customFields"],
8
+ category: [
9
+ "id",
10
+ "name",
11
+ "translated",
12
+ "seoUrl",
13
+ "externalLink",
14
+ "customFields",
15
+ "active",
16
+ "type",
17
+ "description",
18
+ "metaTitle",
19
+ "metaDescription",
20
+ "media",
21
+ ],
22
+ ...MEDIA_INCLUDES,
8
23
  },
9
- });
24
+ };
10
25
 
11
26
  export default defineCachedEventHandler(
12
27
  async (event): Promise<Schemas["Category"]> => {
13
28
  const categoryId = getRouterParam(event, "categoryId")!;
14
- const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
15
29
 
16
- return await $fetch(`${endpoint}/category/${categoryId}`, {
17
- headers: { "sw-access-key": accessToken },
18
- query: { _criteria: criteria },
19
- });
30
+ return await storeApiPost(`/category/${categoryId}`, criteria);
20
31
  },
21
32
  {
22
33
  maxAge: useRuntimeConfig().public.shopBite.cacheTtl.category,
@@ -0,0 +1,14 @@
1
+ import { queryCollection } from "@nuxt/content/server";
2
+
3
+ // The pages query Nuxt Content through these routes instead of
4
+ // `queryCollection()` in the browser: on client-side navigation the latter
5
+ // downloads the SQLite WASM build (865 KB) plus the collection dump (#314).
6
+ export default defineEventHandler(async (event) => {
7
+ const page = await queryCollection(event, "home").first();
8
+
9
+ if (!page) {
10
+ throw createError({ statusCode: 404, statusMessage: "Page not found" });
11
+ }
12
+
13
+ return page;
14
+ });
@@ -0,0 +1,22 @@
1
+ import { queryCollection } from "@nuxt/content/server";
2
+
3
+ // Landing page (content/*.md) by route path; see home.get.ts for why the
4
+ // pages do not query the collection in the browser (#314).
5
+ export default defineEventHandler(async (event) => {
6
+ const { path } = getQuery(event);
7
+
8
+ if (typeof path !== "string" || !path.startsWith("/") || path.length > 256) {
9
+ throw createError({ statusCode: 400, statusMessage: "Invalid path" });
10
+ }
11
+
12
+ const page = await queryCollection(event, "landingpages").path(path).first();
13
+
14
+ if (!page) {
15
+ throw createError({
16
+ statusCode: 404,
17
+ statusMessage: `Page ${path} not found!`,
18
+ });
19
+ }
20
+
21
+ return page;
22
+ });
@@ -1,5 +1,3 @@
1
- import { encodeForQuery } from "@shopware/api-client/helpers";
2
-
3
1
  /**
4
2
  * Fixed projections applied to every listing request. Defined server-side so
5
3
  * clients cannot override includes/associations/limit via query params.
@@ -28,6 +26,7 @@ const BASE_CRITERIA = {
28
26
  "mediaId",
29
27
  ],
30
28
  product_option: ["id", "groupId", "name", "translated", "group"],
29
+ ...MEDIA_INCLUDES,
31
30
  },
32
31
  associations: {
33
32
  cover: {
@@ -71,28 +70,23 @@ function resolveAllowedParams(query: Record<string, unknown>) {
71
70
  export default defineCachedEventHandler(
72
71
  async (event) => {
73
72
  const categoryId = getRouterParam(event, "categoryId")!;
74
- const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
75
73
 
76
74
  const { order, properties, manufacturer, query, p } = resolveAllowedParams(
77
75
  getQuery(event) as Record<string, unknown>,
78
76
  );
79
77
 
80
- const criteria = {
81
- ...BASE_CRITERIA,
82
- ...(order !== undefined && { order }),
83
- ...(properties !== undefined && { properties }),
84
- ...(manufacturer !== undefined && { manufacturer }),
85
- ...(query !== undefined && { query }),
86
- ...(p !== undefined && { p }),
87
- };
88
-
89
- return await $fetch(`${endpoint}/product-listing/${categoryId}`, {
90
- headers: {
91
- "sw-access-key": accessToken,
92
- "sw-include-seo-urls": "true",
78
+ return await storeApiPost(
79
+ `/product-listing/${categoryId}`,
80
+ {
81
+ ...BASE_CRITERIA,
82
+ ...(order !== undefined && { order }),
83
+ ...(properties !== undefined && { properties }),
84
+ ...(manufacturer !== undefined && { manufacturer }),
85
+ ...(query !== undefined && { query }),
86
+ ...(p !== undefined && { p }),
93
87
  },
94
- query: { _criteria: encodeForQuery(criteria) },
95
- });
88
+ { headers: { "sw-include-seo-urls": "true" } },
89
+ );
96
90
  },
97
91
  {
98
92
  maxAge: useRuntimeConfig().public.shopBite.cacheTtl.listing,
@@ -1,27 +1,21 @@
1
- import { encodeForQuery } from "@shopware/api-client/helpers";
2
1
  import type { components } from "~~/api-types/storeApiTypes";
3
2
 
4
3
  type Schemas = components["schemas"];
5
4
 
6
- const criteria = encodeForQuery({
5
+ const criteria = {
7
6
  includes: {
8
7
  cross_selling_element: ["crossSelling", "products"],
9
8
  cross_selling: ["name"],
10
9
  product: ["id", "name", "calculatedPrice", "translated"],
11
10
  calculated_price: ["unitPrice"],
12
11
  },
13
- });
12
+ };
14
13
 
15
14
  export default defineCachedEventHandler(
16
15
  async (event): Promise<Schemas["CrossSellingElement"][]> => {
17
16
  const productId = getRouterParam(event, "productId")!;
18
- const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
19
17
 
20
- return await $fetch(`${endpoint}/product/${productId}/cross-selling`, {
21
- method: "POST",
22
- headers: { "sw-access-key": accessToken },
23
- query: { _criteria: criteria },
24
- });
18
+ return await storeApiPost(`/product/${productId}/cross-selling`, criteria);
25
19
  },
26
20
  {
27
21
  maxAge: useRuntimeConfig().public.shopBite.cacheTtl.crossSelling,
@@ -1,9 +1,8 @@
1
- import { encodeForQuery } from "@shopware/api-client/helpers";
2
1
  import type { components } from "~~/api-types/storeApiTypes";
3
2
 
4
3
  type Schemas = components["schemas"];
5
4
 
6
- const criteria = encodeForQuery({
5
+ const criteria = {
7
6
  includes: {
8
7
  product: [
9
8
  "id",
@@ -28,6 +27,7 @@ const criteria = encodeForQuery({
28
27
  product_configurator_setting: ["id", "optionId", "option", "productId"],
29
28
  product_option: ["id", "groupId", "name", "translated", "group"],
30
29
  category: ["id", "name", "translated"],
30
+ ...MEDIA_INCLUDES,
31
31
  },
32
32
  associations: {
33
33
  cover: { associations: { media: {} } },
@@ -44,7 +44,7 @@ const criteria = encodeForQuery({
44
44
  },
45
45
  },
46
46
  },
47
- });
47
+ };
48
48
 
49
49
  export default defineCachedEventHandler(
50
50
  async (
@@ -54,12 +54,8 @@ export default defineCachedEventHandler(
54
54
  configurator?: Schemas["PropertyGroup"][];
55
55
  }> => {
56
56
  const productId = getRouterParam(event, "productId")!;
57
- const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
58
57
 
59
- return await $fetch(`${endpoint}/product/${productId}`, {
60
- headers: { "sw-access-key": accessToken },
61
- query: { _criteria: criteria },
62
- });
58
+ return await storeApiPost(`/product/${productId}`, criteria);
63
59
  },
64
60
  {
65
61
  maxAge: useRuntimeConfig().public.shopBite.cacheTtl.product,
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Uses `storeUrl` (NUXT_PUBLIC_STORE_URL) as the site URL of nuxt-site-config,
3
+ * so canonical URLs, the sitemap and robots.txt share one base URL instead of
4
+ * the request origin (which is internal behind a reverse proxy).
5
+ */
6
+ export default defineNitroPlugin((nitroApp) => {
7
+ nitroApp.hooks.hook("site-config:init", ({ event, siteConfig }) => {
8
+ const { storeUrl } = useRuntimeConfig(event).public;
9
+ if (storeUrl) {
10
+ siteConfig.push({ _context: "storeUrl", url: storeUrl });
11
+ }
12
+ });
13
+ });
@@ -0,0 +1,26 @@
1
+ import type { StorefrontSitemapUrl } from "../utils/sitemap";
2
+
3
+ const CONTEXT_KEY = "sitemapTrailingSlashPaths";
4
+
5
+ /**
6
+ * The sitemap module normalises every URL to "no trailing slash", which turns
7
+ * Shopware category URLs like `/c/Pizza/` into 404s. Sources mark such URLs
8
+ * with `_trailingSlash`; the paths are collected per request and restored in
9
+ * the rendered XML, so sitemap and canonical URLs match.
10
+ */
11
+ export default defineNitroPlugin((nitroApp) => {
12
+ nitroApp.hooks.hook("sitemap:resolved", ({ urls, event }) => {
13
+ event.context[CONTEXT_KEY] = new Set(
14
+ urls
15
+ .filter((url) => (url as StorefrontSitemapUrl)._trailingSlash)
16
+ .map((url) => url._relativeLoc),
17
+ );
18
+ });
19
+
20
+ nitroApp.hooks.hook("sitemap:output", (ctx) => {
21
+ const paths = ctx.event.context[CONTEXT_KEY] as Set<string> | undefined;
22
+ if (paths?.size) {
23
+ ctx.sitemap = restoreTrailingSlashes(ctx.sitemap, paths);
24
+ }
25
+ });
26
+ });