@shopbite-de/storefront 1.23.2 → 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.
- package/.env.example +19 -0
- package/.github/workflows/build.yaml +1 -1
- package/.github/workflows/ci.yaml +6 -3
- package/.nuxtrc +1 -1
- package/CLAUDE.md +41 -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.vue +37 -53
- package/app/assets/css/main.css +20 -4
- 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/Item.vue +21 -10
- package/app/components/Category/Breadcrumb.vue +11 -12
- package/app/components/Category/Header.vue +9 -3
- package/app/components/Category/Listing.vue +51 -42
- package/app/components/Checkout/PaymentAndDelivery.vue +19 -3
- package/app/components/Checkout/Summary.vue +65 -1
- package/app/components/Cta.vue +4 -2
- package/app/components/Food/MarqueeItem.vue +20 -8
- package/app/components/Footer/Contact.vue +78 -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 +27 -13
- package/app/components/Header/Title.vue +1 -0
- package/app/components/Header.vue +5 -15
- package/app/components/Hero.vue +45 -2
- package/app/components/ImageGallery.vue +11 -5
- package/app/components/Product/Card.vue +9 -3
- package/app/components/Product/CardFooter.vue +22 -12
- package/app/components/User/RegistrationForm.vue +0 -1
- package/app/components/Wishlist.vue +2 -15
- package/app/composables/useAddToCart.ts +13 -13
- 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/{useCategory.ts → useCategoryById.ts} +1 -1
- package/app/composables/useCategorySeo.ts +22 -25
- 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/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/useTrackEvent.ts +29 -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 +10 -4
- 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 +25 -13
- 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 +24 -21
- package/app/plugins/matomo.ts +35 -0
- package/app/utils/hydrateWhenVisible.ts +20 -0
- package/app/utils/media.ts +33 -0
- package/app/utils/openingHours.ts +67 -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 +10 -9
- package/content.config.ts +3 -0
- package/docs/notes/2026-07-05-issue-259-matomo-broken.md +14 -0
- package/docs/notes/2026-09-07-dependency-update.md +113 -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/node.dockerfile +5 -2
- package/nuxt.config.ts +74 -15
- package/package.json +45 -42
- 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/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 +12 -18
- package/server/api/product/[productId]/cross-selling.get.ts +3 -9
- package/server/api/product/[productId].get.ts +4 -8
- 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/nuxt/AddressFields.test.ts +2 -73
- package/test/nuxt/AnimatedSection.test.ts +67 -0
- package/test/nuxt/CartItem.test.ts +95 -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 +20 -6
- package/test/nuxt/useAddToCart.test.ts +34 -1
- 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/useCategoryListing.test.ts +5 -3
- package/test/nuxt/useCheckoutMethodGuard.test.ts +386 -0
- package/test/nuxt/useProductConfigurator.test.ts +4 -1
- 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 +112 -0
- package/test/unit/media.spec.ts +49 -0
- package/test/unit/openingHours.spec.ts +59 -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 +40 -30
- package/test/unit/useSortingSelection.spec.ts +39 -0
- package/tsconfig.json +1 -1
- package/app/composables/useValidCitiesForDelivery.ts +0 -12
|
@@ -9,9 +9,15 @@ interface OrderRouteParams extends RouteParams {
|
|
|
9
9
|
id: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
useSeoMeta({
|
|
13
|
+
title: "Bestellung",
|
|
14
|
+
});
|
|
15
|
+
|
|
12
16
|
const route = useRoute();
|
|
13
17
|
const { id } = route.params as OrderRouteParams;
|
|
14
18
|
const { order, loadOrderDetails, status } = useOrderDetails(id);
|
|
19
|
+
// Shop phone number for the "call us" card; hidden without one (#251).
|
|
20
|
+
const { site } = useRuntimeConfig().public;
|
|
15
21
|
|
|
16
22
|
const isLoadingData = ref(true);
|
|
17
23
|
|
|
@@ -33,8 +39,8 @@ const links = ref<ButtonProps[]>([
|
|
|
33
39
|
</script>
|
|
34
40
|
|
|
35
41
|
<template>
|
|
36
|
-
<!-- Show loading spinner while fetching order data -->
|
|
37
42
|
<UContainer v-if="isLoadingData">
|
|
43
|
+
<!-- Show loading spinner while fetching order data -->
|
|
38
44
|
<UPageHeader headline="BESTELLUNG" title="Lädt..." />
|
|
39
45
|
<UPageBody>
|
|
40
46
|
<div class="flex flex-col items-center justify-center py-16 gap-4">
|
|
@@ -55,7 +61,7 @@ const links = ref<ButtonProps[]>([
|
|
|
55
61
|
/>
|
|
56
62
|
<UPageBody>
|
|
57
63
|
<OrderDetail :order="order" :status="status ?? 'laden...'" />
|
|
58
|
-
<UCard class="mt-6">
|
|
64
|
+
<UCard v-if="site.telephone" class="mt-6">
|
|
59
65
|
<div
|
|
60
66
|
class="flex flex-col sm:flex-row items-start sm:items-center gap-4"
|
|
61
67
|
>
|
|
@@ -67,9 +73,9 @@ const links = ref<ButtonProps[]>([
|
|
|
67
73
|
</p>
|
|
68
74
|
</div>
|
|
69
75
|
<UButton
|
|
70
|
-
label="Jetzt anrufen"
|
|
76
|
+
:label="`Jetzt anrufen: ${site.telephone}`"
|
|
71
77
|
color="primary"
|
|
72
|
-
to="
|
|
78
|
+
:to="toTelHref(site.telephone)"
|
|
73
79
|
icon="i-lucide-phone"
|
|
74
80
|
shrink-0
|
|
75
81
|
/>
|
package/app/pages/c/[...all].vue
CHANGED
|
@@ -6,42 +6,9 @@ definePageMeta({
|
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
const { clearBreadcrumbs } = useBreadcrumbs();
|
|
9
|
-
const {
|
|
10
|
-
const route = useRoute();
|
|
11
|
-
const routePath = route.path;
|
|
9
|
+
const { seoUrl } = await useSeoUrlRoute();
|
|
12
10
|
|
|
13
|
-
const {
|
|
14
|
-
`cmsResponse${routePath}`,
|
|
15
|
-
async () => {
|
|
16
|
-
// For client links if the history state contains seo url information we can omit the api call
|
|
17
|
-
if (import.meta.client) {
|
|
18
|
-
if (history.state?.routeName) {
|
|
19
|
-
return {
|
|
20
|
-
routeName: history.state?.routeName,
|
|
21
|
-
foreignKey: history.state?.foreignKey,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const seoUrl = await resolvePath(routePath);
|
|
26
|
-
|
|
27
|
-
if (!seoUrl?.foreignKey) {
|
|
28
|
-
throw createError({
|
|
29
|
-
statusCode: 404,
|
|
30
|
-
statusMessage: `No data fetched from API for ${routePath}`,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return seoUrl;
|
|
35
|
-
},
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if (error.value) {
|
|
39
|
-
throw error.value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const { foreignKey } = useNavigationContext(
|
|
43
|
-
seoResult as Ref<Schemas["SeoUrl"]>,
|
|
44
|
-
);
|
|
11
|
+
const { foreignKey } = useNavigationContext(seoUrl as Ref<Schemas["SeoUrl"]>);
|
|
45
12
|
|
|
46
13
|
onBeforeRouteLeave(() => {
|
|
47
14
|
clearBreadcrumbs();
|
package/app/pages/index.vue
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
+
// Server route instead of queryCollection(): keeps the SQLite WASM client
|
|
3
|
+
// out of client-side navigations (#314).
|
|
2
4
|
const { data: page } = await useAsyncData("index", () =>
|
|
3
|
-
|
|
5
|
+
$fetch("/api/content/home"),
|
|
4
6
|
);
|
|
5
7
|
if (!page.value) {
|
|
6
8
|
throw createError({
|
|
@@ -10,26 +12,36 @@ if (!page.value) {
|
|
|
10
12
|
});
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
const
|
|
15
|
+
const { site } = useRuntimeConfig().public;
|
|
16
|
+
const homeSite = {
|
|
17
|
+
name: site.name,
|
|
18
|
+
city: site.address.city,
|
|
19
|
+
cuisine: site.cuisine,
|
|
20
|
+
};
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
// Nuxt Content fills seo.title/description from title/description, so only
|
|
23
|
+
// values that differ from those were set explicitly for search engines.
|
|
24
|
+
const { seo, title, description } = page.value;
|
|
25
|
+
const customTitle = seo?.title !== title ? seo?.title : undefined;
|
|
26
|
+
const customDescription =
|
|
27
|
+
seo?.description !== description ? seo?.description : undefined;
|
|
28
|
+
|
|
29
|
+
usePageSeo({
|
|
30
|
+
title: customTitle || buildHomeTitle(homeSite),
|
|
31
|
+
description:
|
|
32
|
+
customDescription || buildHomeDescription(homeSite) || description,
|
|
33
|
+
image: seo?.image as string | undefined,
|
|
34
|
+
standalone: true,
|
|
26
35
|
});
|
|
36
|
+
|
|
37
|
+
useRestaurantSchema();
|
|
27
38
|
</script>
|
|
28
39
|
<template>
|
|
29
40
|
<div v-if="page" class="relative">
|
|
30
41
|
<Hero
|
|
31
42
|
:title="page.title"
|
|
32
43
|
:background-video="page.hero.backgroundVideo"
|
|
44
|
+
:poster="page.hero.poster"
|
|
33
45
|
:description="page.description"
|
|
34
46
|
:headline="page.hero.headline"
|
|
35
47
|
:links="page.hero.links"
|
package/app/pages/kontakt.vue
CHANGED
package/app/pages/merkliste.vue
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
H
|
|
2
1
|
<script setup lang="ts">
|
|
3
2
|
import type { Schemas } from "#shopware";
|
|
4
3
|
|
|
@@ -7,42 +6,9 @@ definePageMeta({
|
|
|
7
6
|
});
|
|
8
7
|
|
|
9
8
|
const { clearBreadcrumbs } = useBreadcrumbs();
|
|
10
|
-
const {
|
|
11
|
-
const route = useRoute();
|
|
12
|
-
const routePath = route.path;
|
|
9
|
+
const { seoUrl } = await useSeoUrlRoute();
|
|
13
10
|
|
|
14
|
-
const {
|
|
15
|
-
`cmsResponse${routePath}`,
|
|
16
|
-
async () => {
|
|
17
|
-
// For client links if the history state contains seo url information we can omit the api call
|
|
18
|
-
if (import.meta.client) {
|
|
19
|
-
if (history.state?.routeName) {
|
|
20
|
-
return {
|
|
21
|
-
routeName: history.state?.routeName,
|
|
22
|
-
foreignKey: history.state?.foreignKey,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const seoUrl = await resolvePath(routePath);
|
|
27
|
-
|
|
28
|
-
if (!seoUrl?.foreignKey) {
|
|
29
|
-
throw createError({
|
|
30
|
-
statusCode: 404,
|
|
31
|
-
statusMessage: `No data fetched from API for ${routePath}`,
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return seoUrl;
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (error.value) {
|
|
40
|
-
throw error.value;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const { foreignKey } = useNavigationContext(
|
|
44
|
-
seoResult as Ref<Schemas["SeoUrl"]>,
|
|
45
|
-
);
|
|
11
|
+
const { foreignKey } = useNavigationContext(seoUrl as Ref<Schemas["SeoUrl"]>);
|
|
46
12
|
|
|
47
13
|
onBeforeRouteLeave(() => {
|
|
48
14
|
clearBreadcrumbs();
|
package/app/pages/suche.vue
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { Schemas } from "#shopware";
|
|
3
3
|
import type { NitroFetchRequest } from "nitropack";
|
|
4
|
+
import ProductCard from "~/components/Product/Card.vue";
|
|
5
|
+
|
|
6
|
+
// Cards hydrate as they scroll into view, see Category/Listing.vue (#314).
|
|
7
|
+
const ProductCardWhenVisible = hydrateWhenVisible(ProductCard);
|
|
4
8
|
|
|
5
9
|
definePageMeta({
|
|
6
10
|
layout: "listing",
|
|
7
11
|
});
|
|
8
12
|
|
|
13
|
+
useSeoMeta({
|
|
14
|
+
title: "Suche",
|
|
15
|
+
});
|
|
16
|
+
|
|
9
17
|
const route = useRoute();
|
|
10
18
|
const router = useRouter();
|
|
11
19
|
const { searchFallbackCategoryId } = useRuntimeConfig().public.shopBite;
|
|
@@ -22,20 +30,21 @@ const {
|
|
|
22
30
|
changeSorting,
|
|
23
31
|
} = useListingSearch(searchQuery.value);
|
|
24
32
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
33
|
+
// Derived from the listing data instead of snapshotted at setup time, which
|
|
34
|
+
// rendered the placeholder on the server and the actual sorting on the
|
|
35
|
+
// client: a hydration mismatch (#295, same as #239 in Category/Listing.vue).
|
|
36
|
+
const { currentSorting } = useSortingSelection(currentSortingOrder);
|
|
37
|
+
|
|
38
|
+
// Re-fetch when the URL query changes (e.g. user searches again from this
|
|
39
|
+
// page). applySearch sends no order, so the response falls back to the
|
|
40
|
+
// default sorting; drop the override so the select follows it.
|
|
41
|
+
watch(searchQuery, (q) => {
|
|
42
|
+
currentSorting.value = SORTING_PLACEHOLDER;
|
|
43
|
+
return applySearch(q);
|
|
37
44
|
});
|
|
38
45
|
|
|
46
|
+
useSearchTracking(searchQuery, elements, showSkeleton);
|
|
47
|
+
|
|
39
48
|
// Fallback: fetch a curated category listing when search returns no results.
|
|
40
49
|
// The category should have a dynamic product group assigned in Shopware.
|
|
41
50
|
const showFallback = computed(
|
|
@@ -65,14 +74,8 @@ watch(showFallback, (visible) => {
|
|
|
65
74
|
}
|
|
66
75
|
});
|
|
67
76
|
|
|
68
|
-
const currentSorting = ref(currentSortingOrder.value ?? "Sortieren");
|
|
69
|
-
|
|
70
|
-
watch(currentSortingOrder, (val) => {
|
|
71
|
-
if (val) currentSorting.value = val;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
77
|
watch(currentSorting, async (val) => {
|
|
75
|
-
if (val === currentSortingOrder.value) return;
|
|
78
|
+
if (val === SORTING_PLACEHOLDER || val === currentSortingOrder.value) return;
|
|
76
79
|
await changeSorting(val, searchQuery.value);
|
|
77
80
|
});
|
|
78
81
|
|
|
@@ -144,7 +147,7 @@ function submitSearch() {
|
|
|
144
147
|
class="flex flex-col gap-4 transition-opacity duration-200"
|
|
145
148
|
:class="{ 'opacity-40 pointer-events-none': loading }"
|
|
146
149
|
>
|
|
147
|
-
<
|
|
150
|
+
<ProductCardWhenVisible
|
|
148
151
|
v-for="product in elements"
|
|
149
152
|
:key="product.id"
|
|
150
153
|
:product="product"
|
|
@@ -160,7 +163,7 @@ function submitSearch() {
|
|
|
160
163
|
<template v-if="showFallback && fallbackProducts?.length">
|
|
161
164
|
<p class="text-sm font-medium mt-2">Das könnte dir gefallen:</p>
|
|
162
165
|
<div class="flex flex-col gap-4">
|
|
163
|
-
<
|
|
166
|
+
<ProductCardWhenVisible
|
|
164
167
|
v-for="product in fallbackProducts"
|
|
165
168
|
:key="product.id"
|
|
166
169
|
:product="product"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Registers Matomo (incl. page view tracking) on every page, but only when it
|
|
2
|
+
// is configured. Replaces the unconditional @nuxt/scripts registry entry (#294).
|
|
3
|
+
//
|
|
4
|
+
// The registry composable is imported after `onNuxtReady`, so its code (and
|
|
5
|
+
// the script it injects) stays off the critical path of the first paint
|
|
6
|
+
// (#314). Page views are pushed here: the registry's own watcher would only
|
|
7
|
+
// hook `page:finish`, which has already fired for the first page.
|
|
8
|
+
export default defineNuxtPlugin({
|
|
9
|
+
name: "shopbite:matomo",
|
|
10
|
+
setup(nuxtApp) {
|
|
11
|
+
if (import.meta.server || !useMatomoConfig().enabled) return;
|
|
12
|
+
|
|
13
|
+
onNuxtReady(async () => {
|
|
14
|
+
const { useMatomo } = await import("~/composables/useMatomo");
|
|
15
|
+
|
|
16
|
+
await nuxtApp.runWithContext(() => {
|
|
17
|
+
if (!useMatomo()) return;
|
|
18
|
+
|
|
19
|
+
const route = useRoute();
|
|
20
|
+
const { trackPageView } = useTrackEvent();
|
|
21
|
+
let lastPath = route.fullPath;
|
|
22
|
+
trackPageView(lastPath);
|
|
23
|
+
|
|
24
|
+
nuxtApp.hook("page:finish", async () => {
|
|
25
|
+
const path = route.fullPath;
|
|
26
|
+
if (path === lastPath) return;
|
|
27
|
+
lastPath = path;
|
|
28
|
+
// The title is applied to the DOM in the next animation frame.
|
|
29
|
+
await nextTick();
|
|
30
|
+
requestAnimationFrame(() => trackPageView(path));
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineAsyncComponent, hydrateOnVisible, type Component } from "vue";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a component so that its server-rendered markup is kept and hydrated
|
|
5
|
+
* only once it comes within `margin` of the viewport (#314).
|
|
6
|
+
*
|
|
7
|
+
* Unlike `<LazyX hydrate-on-visible>`, the component stays in the chunk of
|
|
8
|
+
* the importer: nothing extra is requested before the first instance can
|
|
9
|
+
* hydrate. The margin should exceed the reveal margin of `AnimatedSection`
|
|
10
|
+
* (100px) so the scroll animation still runs after hydration.
|
|
11
|
+
*/
|
|
12
|
+
export function hydrateWhenVisible<T extends Component>(
|
|
13
|
+
component: T,
|
|
14
|
+
margin = "600px",
|
|
15
|
+
): T {
|
|
16
|
+
return defineAsyncComponent({
|
|
17
|
+
loader: () => Promise.resolve(component),
|
|
18
|
+
hydrate: hydrateOnVisible({ rootMargin: `${margin} 0px` }),
|
|
19
|
+
}) as T;
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type Thumbnail = { url?: string; width?: number };
|
|
2
|
+
type Media = {
|
|
3
|
+
url?: string;
|
|
4
|
+
thumbnails?: Thumbnail[] | null;
|
|
5
|
+
metaData?: { width?: number; height?: number } | null;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `srcset` from the Shopware thumbnails of a media entity (e.g. 400, 800
|
|
10
|
+
* and 1920 px wide), so the browser picks the size it needs instead of the
|
|
11
|
+
* original (#273). Returns `undefined` without thumbnails.
|
|
12
|
+
*/
|
|
13
|
+
export function mediaSrcSet(
|
|
14
|
+
media: Media | null | undefined,
|
|
15
|
+
): string | undefined {
|
|
16
|
+
const entries = (media?.thumbnails ?? [])
|
|
17
|
+
.filter(
|
|
18
|
+
(thumbnail): thumbnail is { url: string; width: number } =>
|
|
19
|
+
Boolean(thumbnail.url) && Boolean(thumbnail.width),
|
|
20
|
+
)
|
|
21
|
+
.sort((a, b) => a.width - b.width)
|
|
22
|
+
.map((thumbnail) => `${thumbnail.url} ${thumbnail.width}w`);
|
|
23
|
+
|
|
24
|
+
return entries.length ? entries.join(", ") : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Intrinsic size of a media entity for `width`/`height` attributes (no layout shift). */
|
|
28
|
+
export function mediaSize(
|
|
29
|
+
media: Media | null | undefined,
|
|
30
|
+
): { width: number; height: number } | undefined {
|
|
31
|
+
const { width, height } = media?.metaData ?? {};
|
|
32
|
+
return width && height ? { width, height } : undefined;
|
|
33
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
type BusinessHourLike = {
|
|
2
|
+
/** 1 = Monday … 7 = Sunday */
|
|
3
|
+
dayOfWeek?: number;
|
|
4
|
+
openingTime?: string;
|
|
5
|
+
closingTime?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/** A run of consecutive weekdays with identical opening hours. */
|
|
9
|
+
export type OpeningHoursRow = {
|
|
10
|
+
/** e.g. `Mo` or `Mi–Fr` */
|
|
11
|
+
days: string;
|
|
12
|
+
/** e.g. `["11:30–14:30", "17:30–23:00"]`; empty on closed days */
|
|
13
|
+
intervals: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const DAY_LABELS = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"] as const;
|
|
17
|
+
|
|
18
|
+
const formatTime = (time: string) => time.slice(0, 5);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Groups business hours into display rows: consecutive days (Monday to
|
|
22
|
+
* Sunday) with the same intervals share a row. Returns an empty list if no
|
|
23
|
+
* day has opening hours.
|
|
24
|
+
*/
|
|
25
|
+
export function groupOpeningHours(
|
|
26
|
+
businessHours: BusinessHourLike[],
|
|
27
|
+
): OpeningHoursRow[] {
|
|
28
|
+
const intervalsByDay = DAY_LABELS.map((_, index) =>
|
|
29
|
+
businessHours
|
|
30
|
+
.filter(
|
|
31
|
+
(bh) => bh.dayOfWeek === index + 1 && bh.openingTime && bh.closingTime,
|
|
32
|
+
)
|
|
33
|
+
.sort((a, b) => a.openingTime!.localeCompare(b.openingTime!))
|
|
34
|
+
.map(
|
|
35
|
+
(bh) => `${formatTime(bh.openingTime!)}–${formatTime(bh.closingTime!)}`,
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (intervalsByDay.every((intervals) => intervals.length === 0)) return [];
|
|
40
|
+
|
|
41
|
+
const rows: OpeningHoursRow[] = [];
|
|
42
|
+
let firstDay = 0;
|
|
43
|
+
|
|
44
|
+
for (let day = 1; day <= DAY_LABELS.length; day++) {
|
|
45
|
+
const sameAsGroup =
|
|
46
|
+
day < DAY_LABELS.length &&
|
|
47
|
+
intervalsByDay[day]!.join() === intervalsByDay[firstDay]!.join();
|
|
48
|
+
if (sameAsGroup) continue;
|
|
49
|
+
|
|
50
|
+
const lastDay = day - 1;
|
|
51
|
+
rows.push({
|
|
52
|
+
days:
|
|
53
|
+
firstDay === lastDay
|
|
54
|
+
? DAY_LABELS[firstDay]!
|
|
55
|
+
: `${DAY_LABELS[firstDay]}–${DAY_LABELS[lastDay]}`,
|
|
56
|
+
intervals: intervalsByDay[firstDay]!,
|
|
57
|
+
});
|
|
58
|
+
firstDay = day;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return rows;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** `tel:` link for a displayed phone number, e.g. `+49 6104 71427`. */
|
|
65
|
+
export function toTelHref(telephone: string): string {
|
|
66
|
+
return `tel:${telephone.replace(/[^\d+]/g, "")}`;
|
|
67
|
+
}
|