@shopbite-de/storefront 1.23.3 → 1.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +22 -0
- package/.github/workflows/build.yaml +1 -1
- package/.github/workflows/ci.yaml +6 -3
- package/CLAUDE.md +48 -3
- package/README.md +139 -40
- package/api-gen.config.json +9 -0
- package/api-types/storeApiSchema.shopbite.overrides.json +35 -0
- package/api-types/storeApiTypes.d.ts +95 -81
- package/app/app.config.ts +3 -2
- package/app/app.vue +40 -53
- package/app/assets/css/main.css +36 -4
- package/app/components/AddToWishlist.vue +13 -6
- package/app/components/Address/Fields.vue +2 -21
- package/app/components/AnimatedSection.vue +9 -4
- package/app/components/BottomNavi.vue +9 -2
- package/app/components/Cart/Bar.vue +102 -0
- package/app/components/Cart/Item.vue +21 -10
- package/app/components/Cart/QuickView.vue +4 -0
- package/app/components/Cart/Upsell.vue +106 -0
- package/app/components/Category/Header.vue +9 -3
- package/app/components/Category/Listing.vue +62 -45
- package/app/components/Checkout/PaymentAndDelivery.vue +19 -3
- package/app/components/Checkout/Summary.vue +70 -2
- package/app/components/Cta.vue +4 -2
- package/app/components/DemoBanner.vue +13 -0
- package/app/components/Feature/Card.vue +121 -0
- package/app/components/Features.vue +14 -9
- package/app/components/Food/MarqueeItem.vue +20 -8
- package/app/components/Footer/Contact.vue +82 -0
- package/app/components/Footer/StoreStatus.vue +30 -0
- package/app/components/Footer.vue +2 -1
- package/app/components/Header/Body.vue +1 -1
- package/app/components/Header/Right.vue +60 -17
- package/app/components/Header/Title.vue +1 -0
- package/app/components/Header.vue +5 -15
- package/app/components/Hero.vue +169 -36
- package/app/components/ImageGallery.vue +11 -5
- package/app/components/Product/Card.vue +104 -46
- package/app/components/Product/CardCompact.vue +72 -0
- package/app/components/Product/CardDietBadges.vue +38 -31
- package/app/components/Product/CardIngredients.vue +35 -0
- package/app/components/Product/CardSkeleton.vue +10 -18
- package/app/components/Product/Category.vue +9 -2
- package/app/components/Product/Configurator.vue +11 -7
- package/app/components/Product/CrossSelling.vue +45 -34
- package/app/components/Product/DeselectIngredient.vue +37 -31
- package/app/components/Product/Detail.vue +73 -13
- package/app/components/Product/QuickView.vue +77 -0
- package/app/components/Topseller.vue +44 -34
- package/app/components/User/RegistrationForm.vue +0 -1
- package/app/components/Wishlist.vue +2 -15
- package/app/composables/useAddToCart.ts +13 -40
- package/app/composables/useAddressAutocomplete.ts +12 -19
- package/app/composables/useAddressSuggestionArea.ts +16 -0
- package/app/composables/useAddressValidation.ts +3 -19
- package/app/composables/useCartMutations.ts +168 -0
- package/app/composables/useCartQuickView.ts +19 -0
- package/app/composables/useCartUpsell.ts +100 -0
- package/app/composables/{useCategory.ts → useCategoryById.ts} +1 -1
- package/app/composables/useCategorySeo.ts +27 -29
- package/app/composables/useCheckoutMethodGuard.ts +201 -0
- package/app/composables/useMatomo.ts +25 -0
- package/app/composables/useMatomoConfig.ts +12 -0
- package/app/composables/useMenuSectionSchema.ts +55 -0
- package/app/composables/useNavigation.ts +12 -9
- package/app/composables/usePageSeo.ts +50 -0
- package/app/composables/useProductCartQuantity.ts +15 -0
- package/app/composables/useProductCrossSelling.ts +1 -0
- package/app/composables/useProductDetail.ts +15 -1
- package/app/composables/useProductEvents.ts +30 -0
- package/app/composables/useProductQuickView.ts +65 -0
- package/app/composables/useRestaurantSchema.ts +64 -0
- package/app/composables/useScrollAnimation.ts +39 -8
- package/app/composables/useSearchTracking.ts +33 -0
- package/app/composables/useSeoUrlRoute.ts +58 -0
- package/app/composables/useSortingSelection.ts +28 -0
- package/app/composables/useStoreStatus.ts +48 -0
- package/app/composables/useTopSellers.ts +22 -0
- package/app/composables/useTrackEvent.ts +36 -23
- package/app/pages/[...all].vue +4 -4
- package/app/pages/account/recover/password/index.vue +1 -0
- package/app/pages/anmelden.vue +4 -0
- package/app/pages/bestellung/[id]/erfolg.vue +1 -5
- package/app/pages/bestellung/[id]/fehler.vue +2 -2
- package/app/pages/bestellung/[id]/index.vue +9 -3
- package/app/pages/bestellung/bestaetigen.vue +1 -5
- package/app/pages/bestellung/warenkorb.vue +1 -5
- package/app/pages/bestellung/zahlung-versand.vue +1 -5
- package/app/pages/c/[...all].vue +2 -35
- package/app/pages/index.vue +28 -14
- package/app/pages/kontakt.vue +4 -0
- package/app/pages/konto/adressen.vue +4 -0
- package/app/pages/konto/bestellung/[id].vue +4 -0
- package/app/pages/konto/bestellungen.vue +4 -0
- package/app/pages/konto/index.vue +4 -0
- package/app/pages/konto/profil.vue +4 -0
- package/app/pages/maintenance.vue +6 -0
- package/app/pages/merkliste.vue +1 -7
- package/app/pages/passwort-vergessen.vue +1 -0
- package/app/pages/registrierung/bestaetigen.vue +4 -0
- package/app/pages/registrierung/index.vue +4 -0
- package/app/pages/speisekarte/[...all].vue +2 -36
- package/app/pages/suche.vue +42 -26
- package/app/plugins/matomo.ts +35 -0
- package/app/types/Association.d.ts +1 -0
- package/app/utils/hydrateWhenVisible.ts +20 -0
- package/app/utils/media.ts +33 -0
- package/app/utils/openingHours.ts +90 -0
- package/app/utils/product.ts +31 -0
- package/app/utils/schema.ts +235 -0
- package/app/utils/seo.ts +56 -0
- package/app/utils/seoPath.ts +57 -0
- package/content/index.yml +26 -20
- package/content.config.ts +16 -0
- package/docs/notes/2026-07-05-issue-259-matomo-broken.md +7 -0
- package/docs/notes/2026-09-08-issue-240-shipping-method-blocked.md +83 -0
- package/docs/notes/2026-09-08-issue-241-cart-lock-conflicts.md +63 -0
- package/docs/notes/2026-09-08-issue-244-category-url-trailing-slash.md +65 -0
- package/docs/notes/2026-09-08-issue-276-payment-method-blocked.md +39 -0
- package/docs/notes/2026-09-08-issue-277-typecheck.md +99 -0
- package/docs/notes/2026-09-10-issue-250-animated-section.md +23 -0
- package/docs/notes/2026-09-10-issue-251-shop-data-in-base-layer.md +30 -0
- package/docs/notes/2026-09-10-issue-272-restaurant-schema.md +27 -0
- package/docs/notes/2026-09-10-issue-273-performance-media.md +64 -0
- package/docs/notes/2026-09-10-issue-274-seo-basics.md +49 -0
- package/docs/notes/2026-09-10-issue-275-accessibility.md +46 -0
- package/docs/notes/2026-09-10-issue-290-footer-nap.md +28 -0
- package/docs/notes/2026-09-10-issue-291-seo-url-trailing-slash.md +24 -0
- package/docs/notes/2026-09-10-issue-294-matomo-without-config.md +33 -0
- package/docs/notes/2026-09-10-issue-295-search-hydration-mismatch.md +25 -0
- package/docs/notes/2026-09-10-issue-296-track-direct-search.md +19 -0
- package/docs/notes/2026-09-10-issue-312-store-api-criteria-post.md +64 -0
- package/docs/notes/2026-09-10-issue-313-wishlist-scoped-tailwind.md +29 -0
- package/docs/notes/2026-09-10-issue-314-mobile-js-cost.md +119 -0
- package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +154 -0
- package/docs/notes/2026-09-12-issue-325-product-card.md +100 -0
- package/docs/notes/2026-09-12-issue-327-home-hero.md +64 -0
- package/docs/notes/2026-09-13-demo-banner.md +32 -0
- package/docs/notes/2026-09-13-issue-332-home-info-cards.md +46 -0
- package/docs/notes/2026-09-13-quick-view-flicker.md +65 -0
- package/docs/notes/2026-09-14-cart-upsell.md +105 -0
- package/docs/notes/2026-09-14-demo-noindex.md +57 -0
- package/node.dockerfile +5 -2
- package/nuxt.config.ts +98 -15
- package/package.json +5 -3
- package/patches/@shopware__nuxt-module@1.5.1.patch +32 -0
- package/pnpm-workspace.yaml +2 -0
- package/public/hero-poster.webp +0 -0
- package/scripts/perf/first-render.mjs +30 -0
- package/scripts/perf/h2-proxy.cjs +49 -0
- package/scripts/perf/lighthouse.sh +22 -0
- package/scripts/perf/quick-view-layout.mjs +126 -0
- package/server/api/__sitemap__/urls.get.ts +49 -0
- package/server/api/category/[categoryId].get.ts +20 -9
- package/server/api/content/home.get.ts +14 -0
- package/server/api/content/page.get.ts +22 -0
- package/server/api/listing/[categoryId].get.ts +14 -18
- package/server/api/product/[productId]/cross-selling.get.ts +3 -9
- package/server/api/product/[productId].get.ts +4 -8
- package/server/api/search.get.ts +2 -0
- package/server/plugins/site-url.ts +13 -0
- package/server/plugins/sitemap-trailing-slash.ts +26 -0
- package/server/utils/sitemap.ts +60 -0
- package/server/utils/storeApi.ts +34 -0
- package/shopware.d.ts +35 -11
- package/test/e2e/simple-checkout-as-recurring-customer.test.ts +13 -17
- package/test/nuxt/AddressFields.test.ts +2 -73
- package/test/nuxt/AnimatedSection.test.ts +67 -0
- package/test/nuxt/CartBar.test.ts +110 -0
- package/test/nuxt/CartItem.test.ts +95 -0
- package/test/nuxt/CartUpsell.test.ts +125 -0
- package/test/nuxt/DemoBanner.test.ts +12 -0
- package/test/nuxt/FooterContact.test.ts +102 -0
- package/test/nuxt/FooterStoreStatus.test.ts +48 -0
- package/test/nuxt/HeaderRight.test.ts +14 -10
- package/test/nuxt/Hero.test.ts +68 -0
- package/test/nuxt/PaymentAndDelivery.test.ts +67 -8
- package/test/nuxt/RegistrationForm.test.ts +3 -0
- package/test/nuxt/useAddToCart.test.ts +37 -17
- package/test/nuxt/useAddressAutocomplete.test.ts +2 -38
- package/test/nuxt/useAddressSuggestionArea.test.ts +27 -0
- package/test/nuxt/useBusinessHours.test.ts +1 -1
- package/test/nuxt/useCartMutations.test.ts +225 -0
- package/test/nuxt/useCartUpsell.test.ts +126 -0
- package/test/nuxt/useCheckoutMethodGuard.test.ts +386 -0
- package/test/nuxt/useScrollAnimation.test.ts +55 -49
- package/test/nuxt/useSearchTracking.test.ts +71 -0
- package/test/nuxt/useSeoUrlRoute.test.ts +93 -0
- package/test/nuxt/useStoreStatus.test.ts +77 -0
- package/test/nuxt/useTrackEvent.test.ts +127 -0
- package/test/unit/media.spec.ts +49 -0
- package/test/unit/openingHours.spec.ts +90 -0
- package/test/unit/product.spec.ts +72 -0
- package/test/unit/schema.spec.ts +243 -0
- package/test/unit/seo.spec.ts +107 -0
- package/test/unit/seoPath.spec.ts +116 -0
- package/test/unit/sitemap.spec.ts +88 -0
- package/test/unit/useCategorySeo.spec.ts +42 -31
- package/test/unit/useSortingSelection.spec.ts +39 -0
- package/test/visual/playwright.config.ts +33 -0
- package/test/visual/visual.spec.ts +87 -0
- package/app/components/Product/CardDescription.vue +0 -27
- package/app/components/Product/CardFooter.vue +0 -51
- package/app/composables/useValidCitiesForDelivery.ts +0 -12
package/nuxt.config.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default defineNuxtConfig({
|
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
property: "og:title",
|
|
23
|
-
content:
|
|
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,22 +68,49 @@ 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: "",
|
|
66
79
|
contactForm: false,
|
|
80
|
+
// Shows a non-dismissible notice above the header that the shop
|
|
81
|
+
// is a demo and orders are not fulfilled (demo shops in demos/).
|
|
82
|
+
demoBanner: false,
|
|
67
83
|
},
|
|
68
84
|
},
|
|
69
85
|
site: {
|
|
70
86
|
name: storeName,
|
|
71
87
|
description: storeDescription,
|
|
72
88
|
countryId: "",
|
|
89
|
+
// `%s` = page title, `%siteName` = site.name; the home page renders
|
|
90
|
+
// its title without the template.
|
|
91
|
+
titleTemplate: "%s | %siteName – Online bestellen",
|
|
92
|
+
// Share preview for pages without their own image (path or URL).
|
|
93
|
+
ogImage: "/card.png",
|
|
94
|
+
// Used in the default home page title and description.
|
|
95
|
+
cuisine: "",
|
|
96
|
+
// Shown in the footer (NAP for local SEO, #290) and in the Restaurant
|
|
97
|
+
// schema (#272); empty values are left out.
|
|
98
|
+
address: {
|
|
99
|
+
street: "",
|
|
100
|
+
postalCode: "",
|
|
101
|
+
city: "",
|
|
102
|
+
country: "DE",
|
|
103
|
+
},
|
|
104
|
+
telephone: "",
|
|
105
|
+
googleBusinessProfileUrl: "",
|
|
106
|
+
// Restaurant schema only, e.g. "€€" (#272).
|
|
107
|
+
priceRange: "",
|
|
73
108
|
},
|
|
74
109
|
storeUrl: "",
|
|
75
|
-
// Matomo config
|
|
76
|
-
// registry options
|
|
77
|
-
//
|
|
78
|
-
//
|
|
110
|
+
// Matomo config, runtime-overridable via NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_*
|
|
111
|
+
// env vars. Never set these as registry options: those are inlined into
|
|
112
|
+
// the build and shadow the runtime config (#259). Matomo only loads when
|
|
113
|
+
// both values are set (app/plugins/matomo.ts, #294).
|
|
79
114
|
scripts: {
|
|
80
115
|
matomoAnalytics: {
|
|
81
116
|
matomoUrl: "",
|
|
@@ -99,6 +134,27 @@ export default defineNuxtConfig({
|
|
|
99
134
|
|
|
100
135
|
css: ["~/assets/css/main.css"],
|
|
101
136
|
|
|
137
|
+
fonts: {
|
|
138
|
+
defaults: {
|
|
139
|
+
// Metric fallback faces for the font swap period: only the system
|
|
140
|
+
// fonts of phones (Roboto on Android, Helvetica Neue on iOS). Every
|
|
141
|
+
// family in the font stack costs a system font lookup per text style
|
|
142
|
+
// during the first layout; the five module defaults were ~0.4 s of
|
|
143
|
+
// Style & Layout in Lighthouse mobile (#319).
|
|
144
|
+
fallbacks: {
|
|
145
|
+
"sans-serif": ["Roboto", "Helvetica Neue"],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
|
|
150
|
+
ui: {
|
|
151
|
+
experimental: {
|
|
152
|
+
// Only the theme files of the Nuxt UI components the layers render
|
|
153
|
+
// become Tailwind sources (instead of all 120 components), see #319.
|
|
154
|
+
componentDetection: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
|
|
102
158
|
shopware: {
|
|
103
159
|
endpoint: "",
|
|
104
160
|
accessToken: "",
|
|
@@ -109,6 +165,8 @@ export default defineNuxtConfig({
|
|
|
109
165
|
modules: [
|
|
110
166
|
"@shopware/nuxt-module",
|
|
111
167
|
"@nuxt/image",
|
|
168
|
+
// must be loaded before @nuxt/content for the content integration
|
|
169
|
+
"@nuxtjs/sitemap",
|
|
112
170
|
"@nuxt/content",
|
|
113
171
|
"@nuxtjs/robots",
|
|
114
172
|
"@vite-pwa/nuxt",
|
|
@@ -206,6 +264,32 @@ export default defineNuxtConfig({
|
|
|
206
264
|
compatibilityDate: "2025-07-15",
|
|
207
265
|
|
|
208
266
|
vite: {
|
|
267
|
+
build: {
|
|
268
|
+
// Vite 8 bundles with Rolldown; `rollupOptions` would drop this key.
|
|
269
|
+
rolldownOptions: {
|
|
270
|
+
output: {
|
|
271
|
+
// Rolldown code splitting: the framework and UI libraries used by
|
|
272
|
+
// more than one chunk go into two shared chunks instead of ~60
|
|
273
|
+
// tiny ones, which halves the module preloads of every page (#314).
|
|
274
|
+
codeSplitting: {
|
|
275
|
+
groups: [
|
|
276
|
+
{
|
|
277
|
+
name: "framework",
|
|
278
|
+
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)[@/]/,
|
|
279
|
+
minShareCount: 2,
|
|
280
|
+
priority: 20,
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "ui",
|
|
284
|
+
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)[@/]/,
|
|
285
|
+
minShareCount: 2,
|
|
286
|
+
priority: 10,
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
},
|
|
209
293
|
optimizeDeps: {
|
|
210
294
|
include: [
|
|
211
295
|
"@vue/devtools-core",
|
|
@@ -224,11 +308,20 @@ export default defineNuxtConfig({
|
|
|
224
308
|
asyncContext: true,
|
|
225
309
|
payloadExtraction: true,
|
|
226
310
|
watcher: "parcel",
|
|
311
|
+
defaults: {
|
|
312
|
+
nuxtLink: {
|
|
313
|
+
// Prefetch route chunks on hover/touch instead of for every link in
|
|
314
|
+
// view: the header alone pulled ~20 chunks and a page stylesheet
|
|
315
|
+
// during the initial load (#314).
|
|
316
|
+
prefetchOn: { visibility: false, interaction: true },
|
|
317
|
+
},
|
|
318
|
+
},
|
|
227
319
|
},
|
|
228
320
|
$development: {
|
|
229
321
|
modules: [
|
|
230
322
|
"@shopware/nuxt-module",
|
|
231
323
|
"@nuxt/image",
|
|
324
|
+
"@nuxtjs/sitemap",
|
|
232
325
|
"@nuxt/content",
|
|
233
326
|
"@nuxtjs/robots",
|
|
234
327
|
"@nuxt/ui",
|
|
@@ -238,14 +331,4 @@ export default defineNuxtConfig({
|
|
|
238
331
|
"@nuxt/hints",
|
|
239
332
|
],
|
|
240
333
|
},
|
|
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
334
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbite-de/storefront",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.25.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.
|
|
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": "
|
|
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;
|
package/pnpm-workspace.yaml
CHANGED
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// First UpdateLayoutTree + first Layout duration of a page through the h2
|
|
2
|
+
// proxy (mobile viewport, CPU throttle RATE, default 4), median of N runs.
|
|
3
|
+
// node scripts/perf/first-render.mjs / /c/Pizza/
|
|
4
|
+
// BLOCK='\.woff2$' node scripts/perf/first-render.mjs / # abort matching requests
|
|
5
|
+
import { chromium } from 'playwright';
|
|
6
|
+
const paths = process.argv.slice(2); const N = Number(process.env.N || 3);
|
|
7
|
+
const browser = await chromium.launch({ args: ['--ignore-certificate-errors'] });
|
|
8
|
+
const med = (a) => { const s = [...a].sort((x, y) => x - y); return s[Math.floor(s.length / 2)]; };
|
|
9
|
+
for (const p of paths) {
|
|
10
|
+
const rs = [], ls = [], rt = [], lt = []; let rendered = 0;
|
|
11
|
+
for (let i = 0; i < N; i++) {
|
|
12
|
+
const ctx = await browser.newContext({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true, deviceScaleFactor: 2, ignoreHTTPSErrors: true });
|
|
13
|
+
if (process.env.BLOCK) await ctx.route(new RegExp(process.env.BLOCK), (r) => r.abort());
|
|
14
|
+
const page = await ctx.newPage(); const cdp = await ctx.newCDPSession(page);
|
|
15
|
+
await cdp.send('Emulation.setCPUThrottlingRate', { rate: Number(process.env.RATE || 4) });
|
|
16
|
+
await cdp.send('Tracing.start', { categories: 'devtools.timeline,disabled-by-default-devtools.timeline', transferMode: 'ReportEvents' });
|
|
17
|
+
const ev = []; cdp.on('Tracing.dataCollected', (e) => ev.push(...e.value));
|
|
18
|
+
await page.goto('https://localhost:3443' + p, { waitUntil: 'load' }); await page.waitForTimeout(1500);
|
|
19
|
+
rendered = await page.evaluate(() => [...document.querySelectorAll('*')].filter((e) => e.getClientRects().length).length);
|
|
20
|
+
await cdp.send('Tracing.end'); await new Promise((r) => cdp.on('Tracing.tracingComplete', r));
|
|
21
|
+
const x = ev.filter((e) => e.ph === 'X' && (e.name === 'UpdateLayoutTree' || e.name === 'Layout')).sort((a, b) => a.ts - b.ts);
|
|
22
|
+
const big = (n) => x.filter((e) => e.name === n && e.dur > 2000);
|
|
23
|
+
const r = big('UpdateLayoutTree'), l = big('Layout');
|
|
24
|
+
rs.push(r.length ? r[0].dur / 1000 : 0); ls.push(l.length ? l[0].dur / 1000 : 0);
|
|
25
|
+
rt.push(x.filter((e) => e.name === 'UpdateLayoutTree').reduce((s, e) => s + e.dur, 0) / 1000); lt.push(x.filter((e) => e.name === 'Layout').reduce((s, e) => s + e.dur, 0) / 1000);
|
|
26
|
+
await ctx.close();
|
|
27
|
+
}
|
|
28
|
+
console.log(`${p.padEnd(18)} first recalc ${med(rs).toFixed(1).padStart(6)} ms first layout ${med(ls).toFixed(1).padStart(6)} ms | total recalc ${med(rt).toFixed(0).padStart(4)} ms total layout ${med(lt).toFixed(0).padStart(4)} ms (median of ${N}) rendered=${rendered}`);
|
|
29
|
+
}
|
|
30
|
+
await browser.close();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// TLS + HTTP/2 + gzip reverse proxy in front of the Nitro server so that
|
|
2
|
+
// Lighthouse sees production-like transport (docs/notes/2026-09-10-issue-273-performance-media.md).
|
|
3
|
+
//
|
|
4
|
+
// openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 30 -subj "/CN=localhost"
|
|
5
|
+
// PORT=3099 node --env-file=.env .output/server/index.mjs
|
|
6
|
+
// node scripts/perf/h2-proxy.cjs # https://localhost:3443 -> :3099
|
|
7
|
+
//
|
|
8
|
+
// Files in scripts/perf/exp/ are served at /exp/ (static page variants, #319).
|
|
9
|
+
// key.pem, cert.pem and exp/ are git-ignored.
|
|
10
|
+
const http2 = require('http2');
|
|
11
|
+
const http = require('http');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const zlib = require('zlib');
|
|
14
|
+
const path = require('path');
|
|
15
|
+
const upstreamPort = Number(process.env.UPSTREAM_PORT || 3099);
|
|
16
|
+
const listenPort = Number(process.env.PORT || 3443);
|
|
17
|
+
const server = http2.createSecureServer({
|
|
18
|
+
key: fs.readFileSync(path.join(__dirname, 'key.pem')),
|
|
19
|
+
cert: fs.readFileSync(path.join(__dirname, 'cert.pem')),
|
|
20
|
+
allowHTTP1: true,
|
|
21
|
+
});
|
|
22
|
+
const types = { html: 'text/html; charset=utf-8', css: 'text/css', js: 'text/javascript', json: 'application/json', woff2: 'font/woff2', webp: 'image/webp', png: 'image/png', svg: 'image/svg+xml' };
|
|
23
|
+
server.on('request', (req, res) => {
|
|
24
|
+
if (req.url.startsWith('/exp/')) {
|
|
25
|
+
const file = path.join(__dirname, 'exp', req.url.slice(5).split('?')[0]);
|
|
26
|
+
if (!fs.existsSync(file)) { res.writeHead(404); res.end('nope'); return; }
|
|
27
|
+
const ext = file.split('.').pop(); const body = fs.readFileSync(file);
|
|
28
|
+
const type = types[ext] || 'application/octet-stream';
|
|
29
|
+
if (/text|javascript|json|svg/.test(type)) { res.writeHead(200, { 'content-type': type, 'content-encoding': 'gzip', 'cache-control': 'no-store' }); res.end(zlib.gzipSync(body)); }
|
|
30
|
+
else { res.writeHead(200, { 'content-type': type, 'cache-control': 'no-store' }); res.end(body); }
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const headers = { ...req.headers };
|
|
34
|
+
delete headers[':method']; delete headers[':path']; delete headers[':scheme']; delete headers[':authority'];
|
|
35
|
+
headers.host = 'localhost:' + upstreamPort;
|
|
36
|
+
headers['accept-encoding'] = 'identity';
|
|
37
|
+
const up = http.request({ host: '127.0.0.1', port: upstreamPort, method: req.method, path: req.url, headers }, (ur) => {
|
|
38
|
+
const h = { ...ur.headers };
|
|
39
|
+
delete h.connection; delete h['transfer-encoding']; delete h['keep-alive'];
|
|
40
|
+
const type = h['content-type'] || '';
|
|
41
|
+
const compressible = /text|javascript|json|xml|svg/.test(type) && !h['content-encoding'];
|
|
42
|
+
if (compressible) { h['content-encoding'] = 'gzip'; delete h['content-length']; }
|
|
43
|
+
res.writeHead(ur.statusCode, h);
|
|
44
|
+
if (compressible) ur.pipe(zlib.createGzip({ level: 6 })).pipe(res); else ur.pipe(res);
|
|
45
|
+
});
|
|
46
|
+
up.on('error', (e) => { res.writeHead(502); res.end(String(e)); });
|
|
47
|
+
req.pipe(up);
|
|
48
|
+
});
|
|
49
|
+
server.listen(listenPort, () => console.log('h2 proxy on https://localhost:' + listenPort + ' -> :' + upstreamPort));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Lighthouse mobile run against the h2 proxy with the main-thread breakdown.
|
|
3
|
+
# usage: scripts/perf/lighthouse.sh <label> <path> [runs]
|
|
4
|
+
# Needs Lighthouse (npx lighthouse) and a Chrome binary in CHROME_PATH
|
|
5
|
+
# (e.g. the Playwright Chromium: ~/.cache/ms-playwright/chromium-*/chrome-linux64/chrome).
|
|
6
|
+
# LH_EXTRA="--save-assets" keeps the trace next to the JSON.
|
|
7
|
+
S=${LH_OUT:-scripts/perf/out}
|
|
8
|
+
LABEL=$1; P=$2; RUNS=${3:-2}
|
|
9
|
+
export CHROME_PATH=${CHROME_PATH:-$(ls -d "$HOME"/.cache/ms-playwright/chromium-*/chrome-linux64/chrome 2>/dev/null | tail -1)}
|
|
10
|
+
LH=${LIGHTHOUSE:-lighthouse}
|
|
11
|
+
mkdir -p "$S/lh"
|
|
12
|
+
for i in $(seq 1 $RUNS); do
|
|
13
|
+
$LH "https://localhost:3443$P" --quiet --output=json --output-path=$S/lh/$LABEL-$i.json \
|
|
14
|
+
--form-factor=mobile --screenEmulation.mobile --throttling-method=simulate \
|
|
15
|
+
--only-categories=performance ${LH_EXTRA:-} --chrome-flags="--headless=new --ignore-certificate-errors --no-sandbox" >/dev/null 2>&1
|
|
16
|
+
node -e '
|
|
17
|
+
const r=require(process.argv[1]); const a=r.audits;
|
|
18
|
+
const mt=a["mainthread-work-breakdown"].details.items; const g=k=>{const i=mt.find(x=>x.group===k);return i?Math.round(i.duration):0};
|
|
19
|
+
const css=(a["network-requests"].details.items||[]).filter(x=>x.resourceType==="Stylesheet").map(x=>x.url.split("/").pop()+" "+Math.round(x.transferSize/1024)+"KB");
|
|
20
|
+
console.log(process.argv[2], "perf", Math.round(r.categories.performance.score*100), "FCP", Math.round(a["first-contentful-paint"].numericValue), "LCP", Math.round(a["largest-contentful-paint"].numericValue), "TBT", Math.round(a["total-blocking-time"].numericValue), "| style&layout", g("styleLayout"), "script", g("scriptEvaluation"), "parseHTML", g("parseHTML"), "paint", g("paintCompositeRender"), "total", Math.round(mt.reduce((s,x)=>s+x.duration,0)), "| dom", a["dom-size"].numericValue, "| css:", css.join(", "));
|
|
21
|
+
' $S/lh/$LABEL-$i.json "$LABEL#$i"
|
|
22
|
+
done
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Logs the quick view drawer body per animation frame after opening it and
|
|
2
|
+
// after switching a variant, collapsed to the distinct layout states, plus
|
|
3
|
+
// the /api/product requests (docs/notes/2026-09-13-quick-view-flicker.md).
|
|
4
|
+
//
|
|
5
|
+
// BASE_URL=http://localhost:3000 node scripts/perf/quick-view-layout.mjs
|
|
6
|
+
// MOBILE=1 OUT=/tmp node scripts/perf/quick-view-layout.mjs
|
|
7
|
+
//
|
|
8
|
+
// Expects a listing at CATEGORY_PATH (default /c/Salate/) containing a card
|
|
9
|
+
// whose name matches PRODUCT (default "Insalata di Pollo") with variants.
|
|
10
|
+
import { chromium } from "@playwright/test";
|
|
11
|
+
const base = process.env.BASE_URL ?? "http://localhost:3000";
|
|
12
|
+
const mobile = process.env.MOBILE === "1";
|
|
13
|
+
const browser = await chromium.launch();
|
|
14
|
+
const ctx = await browser.newContext(
|
|
15
|
+
mobile
|
|
16
|
+
? { viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true }
|
|
17
|
+
: { viewport: { width: 1280, height: 800 } },
|
|
18
|
+
);
|
|
19
|
+
const page = await ctx.newPage();
|
|
20
|
+
page.on("request", (r) => {
|
|
21
|
+
if (r.url().includes("/api/product"))
|
|
22
|
+
console.log(
|
|
23
|
+
" ->",
|
|
24
|
+
Math.round(performance.now() - (globalThis.__t0 ?? 0)),
|
|
25
|
+
"ms",
|
|
26
|
+
r.method(),
|
|
27
|
+
r.url().replace(base, ""),
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
page.on("response", (r) => {
|
|
31
|
+
if (r.url().includes("/api/product"))
|
|
32
|
+
console.log(
|
|
33
|
+
" <-",
|
|
34
|
+
Math.round(performance.now() - (globalThis.__t0 ?? 0)),
|
|
35
|
+
"ms",
|
|
36
|
+
r.status(),
|
|
37
|
+
r.url().replace(base, ""),
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
await page.goto(`${base}${process.env.CATEGORY_PATH ?? "/c/Salate/"}`, {
|
|
41
|
+
waitUntil: "networkidle",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
async function record(label, action, ms = 2500) {
|
|
45
|
+
globalThis.__t0 = performance.now();
|
|
46
|
+
await page.evaluate(() => {
|
|
47
|
+
window.__log = [];
|
|
48
|
+
window.__t0 = performance.now();
|
|
49
|
+
const tick = () => {
|
|
50
|
+
const body = document.querySelector('[data-slot="body"]');
|
|
51
|
+
const content = document.querySelector('[data-slot="content"]');
|
|
52
|
+
window.__log.push({
|
|
53
|
+
t: Math.round(performance.now() - window.__t0),
|
|
54
|
+
content: content
|
|
55
|
+
? Math.round(content.getBoundingClientRect().height)
|
|
56
|
+
: null,
|
|
57
|
+
body: body ? Math.round(body.scrollHeight) : null,
|
|
58
|
+
skeletons: body ? body.querySelectorAll(".animate-pulse").length : 0,
|
|
59
|
+
combos: body ? body.querySelectorAll('[role="combobox"]').length : 0,
|
|
60
|
+
chips: body ? body.querySelectorAll('[role="group"] button').length : 0,
|
|
61
|
+
});
|
|
62
|
+
if (performance.now() - window.__t0 < 6000) requestAnimationFrame(tick);
|
|
63
|
+
};
|
|
64
|
+
requestAnimationFrame(tick);
|
|
65
|
+
});
|
|
66
|
+
await action();
|
|
67
|
+
await page.waitForTimeout(ms);
|
|
68
|
+
const log = await page.evaluate(() => window.__log);
|
|
69
|
+
// Collapse consecutive identical states.
|
|
70
|
+
const steps = [];
|
|
71
|
+
for (const entry of log) {
|
|
72
|
+
const key = JSON.stringify([
|
|
73
|
+
entry.content,
|
|
74
|
+
entry.body,
|
|
75
|
+
entry.skeletons,
|
|
76
|
+
entry.combos,
|
|
77
|
+
entry.chips,
|
|
78
|
+
]);
|
|
79
|
+
if (!steps.length || steps[steps.length - 1].key !== key)
|
|
80
|
+
steps.push({ key, ...entry });
|
|
81
|
+
}
|
|
82
|
+
console.log(`\n== ${label}: ${steps.length - 1} state changes`);
|
|
83
|
+
for (const s of steps)
|
|
84
|
+
console.log(
|
|
85
|
+
` t=${String(s.t).padStart(4)}ms content=${s.content} body=${s.body} skeletons=${s.skeletons} selects=${s.combos} chips=${s.chips}`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
await record("open quick view", async () => {
|
|
90
|
+
await page
|
|
91
|
+
.getByText(process.env.PRODUCT ?? "Insalata di Pollo", { exact: false })
|
|
92
|
+
.first()
|
|
93
|
+
.click();
|
|
94
|
+
});
|
|
95
|
+
await page.screenshot({
|
|
96
|
+
path: `${process.env.OUT ?? "."}/open-${mobile ? "mobile" : "desktop"}.png`,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await record("switch variant", async () => {
|
|
100
|
+
const combo = page.locator('[data-slot="body"] [role="combobox"]').first();
|
|
101
|
+
const current = (await combo.innerText()).trim();
|
|
102
|
+
await combo.click();
|
|
103
|
+
const listbox = page.getByRole("listbox");
|
|
104
|
+
await listbox.waitFor({ state: "visible" });
|
|
105
|
+
const options = listbox.getByRole("option");
|
|
106
|
+
const texts = await options.allInnerTexts();
|
|
107
|
+
console.log(
|
|
108
|
+
" options:",
|
|
109
|
+
texts.map((t) => t.trim()).join(" | "),
|
|
110
|
+
"current:",
|
|
111
|
+
current,
|
|
112
|
+
);
|
|
113
|
+
const idx = texts.findIndex((t) => t.trim() !== current);
|
|
114
|
+
await options.nth(idx).click();
|
|
115
|
+
await page.waitForFunction(
|
|
116
|
+
(c) =>
|
|
117
|
+
document
|
|
118
|
+
.querySelector('[data-slot="body"] [role="combobox"]')
|
|
119
|
+
?.innerText.trim() !== c,
|
|
120
|
+
current,
|
|
121
|
+
);
|
|
122
|
+
});
|
|
123
|
+
await page.screenshot({
|
|
124
|
+
path: `${process.env.OUT ?? "."}/variant-${mobile ? "mobile" : "desktop"}.png`,
|
|
125
|
+
});
|
|
126
|
+
await browser.close();
|
|
@@ -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
|
-
|
|
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: [
|
|
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
|
|
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
|
+
});
|