@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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matomo script, or `null` if Matomo is not configured.
|
|
3
|
+
*
|
|
4
|
+
* Without `matomoUrl` the @nuxt/scripts registry falls back to
|
|
5
|
+
* `https://cdn.matomo.cloud/<cloudId>/matomo.js` and requests
|
|
6
|
+
* `https://cdn.matomo.cloud/undefined/matomo.js` on every page (#294), so the
|
|
7
|
+
* script must only be created with a complete config. The values come from
|
|
8
|
+
* `runtimeConfig.public.scripts.matomoAnalytics` (NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_*),
|
|
9
|
+
* which the registry merges in itself (#259).
|
|
10
|
+
*
|
|
11
|
+
* Only `plugins/matomo.ts` imports this composable, dynamically after
|
|
12
|
+
* `onNuxtReady`, so the registry code stays out of the entry chunk (#314).
|
|
13
|
+
* Page views are tracked by the plugin (`watch: false`): the registry's
|
|
14
|
+
* own page watcher hooks `page:finish`, which has already fired for the
|
|
15
|
+
* first page by then. Tracking calls go through `useTrackEvent`, which
|
|
16
|
+
* writes to the `_paq` queue directly.
|
|
17
|
+
*/
|
|
18
|
+
export function useMatomo() {
|
|
19
|
+
if (!useMatomoConfig().enabled) return null;
|
|
20
|
+
|
|
21
|
+
return useScriptMatomoAnalytics({
|
|
22
|
+
watch: false,
|
|
23
|
+
scriptOptions: { trigger: "onNuxtReady" },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matomo settings from `runtimeConfig.public.scripts.matomoAnalytics`
|
|
3
|
+
* (NUXT_PUBLIC_SCRIPTS_MATOMO_ANALYTICS_*). `enabled` is only true with a
|
|
4
|
+
* complete configuration (#294). Kept apart from `useMatomo` so callers that
|
|
5
|
+
* only need the flag do not import the @nuxt/scripts registry (#314).
|
|
6
|
+
*/
|
|
7
|
+
export function useMatomoConfig() {
|
|
8
|
+
const { matomoUrl, siteId } =
|
|
9
|
+
useRuntimeConfig().public.scripts.matomoAnalytics;
|
|
10
|
+
|
|
11
|
+
return { matomoUrl, siteId, enabled: Boolean(matomoUrl && siteId) };
|
|
12
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
3
|
+
import { buildMenuSectionSchema } from "../utils/schema";
|
|
4
|
+
import { toAbsoluteUrl } from "../utils/seo";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `MenuSection` JSON-LD for a category page (#272): the category with its
|
|
8
|
+
* products as `MenuItem`s incl. prices, from the listing that is loaded for
|
|
9
|
+
* the page anyway.
|
|
10
|
+
*/
|
|
11
|
+
export function useMenuSectionSchema(
|
|
12
|
+
category: Ref<Schemas["Category"] | undefined>,
|
|
13
|
+
products: Ref<Schemas["Product"][]>,
|
|
14
|
+
) {
|
|
15
|
+
const siteConfig = useSiteConfig();
|
|
16
|
+
const { currencyCode } = useCommercePrice();
|
|
17
|
+
|
|
18
|
+
const schema = computed(() => {
|
|
19
|
+
const current = category.value;
|
|
20
|
+
if (!current) return undefined;
|
|
21
|
+
|
|
22
|
+
return buildMenuSectionSchema({
|
|
23
|
+
name: current.translated?.name ?? current.name,
|
|
24
|
+
description:
|
|
25
|
+
current.translated?.description ?? current.description ?? undefined,
|
|
26
|
+
url: current.seoUrl
|
|
27
|
+
? toAbsoluteUrl(siteConfig.url, current.seoUrl)
|
|
28
|
+
: undefined,
|
|
29
|
+
image: current.media?.url,
|
|
30
|
+
currency: currencyCode.value,
|
|
31
|
+
restaurantUrl: siteConfig.url,
|
|
32
|
+
items: products.value.map((product) => ({
|
|
33
|
+
name: product.translated?.name ?? product.name,
|
|
34
|
+
description:
|
|
35
|
+
product.translated?.description ?? product.description ?? undefined,
|
|
36
|
+
image: product.cover?.media?.url,
|
|
37
|
+
price: product.calculatedPrice?.unitPrice,
|
|
38
|
+
})),
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
useHead(() => ({
|
|
43
|
+
script: schema.value
|
|
44
|
+
? [
|
|
45
|
+
{
|
|
46
|
+
key: "jsonld-menu-section",
|
|
47
|
+
type: "application/ld+json",
|
|
48
|
+
innerHTML: JSON.stringify(schema.value),
|
|
49
|
+
},
|
|
50
|
+
]
|
|
51
|
+
: [],
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
return { schema };
|
|
55
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
2
|
-
import { encodeForQuery } from "@shopware/api-client/helpers";
|
|
3
2
|
import type { Schemas } from "#shopware";
|
|
4
3
|
|
|
5
4
|
export function useNavigation(withChildren: boolean | undefined) {
|
|
@@ -9,9 +8,13 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
9
8
|
() => config.public.shopBite.menuCategoryId ?? "main-navigation",
|
|
10
9
|
);
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
// Sent as a POST body: as `_criteria` query parameters the projection is
|
|
12
|
+
// ignored and every category arrives with media, translations, cms page
|
|
13
|
+
// and more (#312).
|
|
14
|
+
const criteria = {
|
|
13
15
|
includes: {
|
|
14
16
|
category: [
|
|
17
|
+
"id",
|
|
15
18
|
"name",
|
|
16
19
|
"translated",
|
|
17
20
|
"seoUrl",
|
|
@@ -20,13 +23,13 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
20
23
|
"linkNewTab",
|
|
21
24
|
],
|
|
22
25
|
},
|
|
23
|
-
}
|
|
26
|
+
};
|
|
24
27
|
|
|
25
28
|
const { data: mainNavigation } = useAsyncData("main-navigation", async () => {
|
|
26
29
|
const response = await apiClient.invoke(
|
|
27
|
-
"
|
|
30
|
+
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
28
31
|
{
|
|
29
|
-
|
|
32
|
+
body: criteria,
|
|
30
33
|
pathParams: {
|
|
31
34
|
activeId: "main-navigation",
|
|
32
35
|
rootId: "main-navigation",
|
|
@@ -61,9 +64,9 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
61
64
|
"footer-navigation",
|
|
62
65
|
async () => {
|
|
63
66
|
const response = await apiClient.invoke(
|
|
64
|
-
"
|
|
67
|
+
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
65
68
|
{
|
|
66
|
-
|
|
69
|
+
body: criteria,
|
|
67
70
|
pathParams: {
|
|
68
71
|
activeId: "footer-navigation",
|
|
69
72
|
rootId: "footer-navigation",
|
|
@@ -85,9 +88,9 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
85
88
|
"menu-category",
|
|
86
89
|
async () => {
|
|
87
90
|
const response = await apiClient.invoke(
|
|
88
|
-
"
|
|
91
|
+
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
89
92
|
{
|
|
90
|
-
|
|
93
|
+
body: criteria,
|
|
91
94
|
pathParams: {
|
|
92
95
|
activeId: "main-navigation",
|
|
93
96
|
rootId: menuCategoryId.value,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter } from "vue";
|
|
2
|
+
import { formatPageTitle, toAbsoluteUrl } from "../utils/seo";
|
|
3
|
+
|
|
4
|
+
type PageSeo = {
|
|
5
|
+
title: MaybeRefOrGetter<string | undefined>;
|
|
6
|
+
description?: MaybeRefOrGetter<string | undefined>;
|
|
7
|
+
/** Site-relative path or absolute URL; falls back to `site.ogImage`. */
|
|
8
|
+
image?: MaybeRefOrGetter<string | undefined>;
|
|
9
|
+
/** Render the title without the site title template (home page). */
|
|
10
|
+
standalone?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Title, description and share preview of an indexable page. Canonical,
|
|
15
|
+
* og:url and the fallback og:image are set globally in app.vue.
|
|
16
|
+
*/
|
|
17
|
+
export function usePageSeo({
|
|
18
|
+
title,
|
|
19
|
+
description,
|
|
20
|
+
image,
|
|
21
|
+
standalone = false,
|
|
22
|
+
}: PageSeo) {
|
|
23
|
+
const { site } = useRuntimeConfig().public;
|
|
24
|
+
const siteConfig = useSiteConfig();
|
|
25
|
+
|
|
26
|
+
const fullTitle = computed(() =>
|
|
27
|
+
standalone
|
|
28
|
+
? (toValue(title) ?? site.name)
|
|
29
|
+
: formatPageTitle(toValue(title), site.name, site.titleTemplate),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const imageUrl = computed(() => {
|
|
33
|
+
const path = toValue(image);
|
|
34
|
+
return path ? toAbsoluteUrl(siteConfig.url, path) : undefined;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
useSeoMeta({
|
|
38
|
+
title,
|
|
39
|
+
titleTemplate: standalone ? "%s" : undefined,
|
|
40
|
+
ogTitle: fullTitle,
|
|
41
|
+
twitterTitle: fullTitle,
|
|
42
|
+
description,
|
|
43
|
+
ogDescription: description,
|
|
44
|
+
twitterDescription: description,
|
|
45
|
+
ogImage: imageUrl,
|
|
46
|
+
twitterImage: imageUrl,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
return { fullTitle, imageUrl };
|
|
50
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
2
|
+
import { buildRestaurantSchema, type MenuSectionInfo } from "../utils/schema";
|
|
3
|
+
import { toAbsoluteUrl } from "../utils/seo";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `Restaurant` JSON-LD for the home page (#272): shop data from
|
|
7
|
+
* `runtimeConfig.public.site`, weekly hours and closing days from the ShopBite
|
|
8
|
+
* plugin, the menu sections from the menu navigation. Hours and holidays are
|
|
9
|
+
* prefetched on the server so the schema is part of the HTML.
|
|
10
|
+
*/
|
|
11
|
+
export function useRestaurantSchema() {
|
|
12
|
+
const { site } = useRuntimeConfig().public;
|
|
13
|
+
const siteConfig = useSiteConfig();
|
|
14
|
+
const { businessHours, refresh: refreshBusinessHours } = useBusinessHours();
|
|
15
|
+
const { holidays, refresh: refreshHolidays } = useHolidays();
|
|
16
|
+
const { menuCardMenu } = useNavigation(true);
|
|
17
|
+
|
|
18
|
+
onServerPrefetch(() =>
|
|
19
|
+
Promise.all([refreshBusinessHours(), refreshHolidays()]),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const toSection = (item: NavigationMenuItem): MenuSectionInfo => ({
|
|
23
|
+
name: item.label ?? "",
|
|
24
|
+
url:
|
|
25
|
+
typeof item.to === "string"
|
|
26
|
+
? toAbsoluteUrl(siteConfig.url, item.to)
|
|
27
|
+
: undefined,
|
|
28
|
+
sections: item.children?.map(toSection),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const schema = computed(() =>
|
|
32
|
+
buildRestaurantSchema({
|
|
33
|
+
site: {
|
|
34
|
+
name: site.name,
|
|
35
|
+
description: site.description,
|
|
36
|
+
url: siteConfig.url,
|
|
37
|
+
image: site.ogImage
|
|
38
|
+
? toAbsoluteUrl(siteConfig.url, site.ogImage)
|
|
39
|
+
: undefined,
|
|
40
|
+
telephone: site.telephone,
|
|
41
|
+
cuisine: site.cuisine,
|
|
42
|
+
priceRange: site.priceRange,
|
|
43
|
+
googleBusinessProfileUrl: site.googleBusinessProfileUrl,
|
|
44
|
+
address: site.address,
|
|
45
|
+
},
|
|
46
|
+
businessHours: businessHours.value ?? [],
|
|
47
|
+
holidays: holidays.value ?? [],
|
|
48
|
+
menuUrl: toAbsoluteUrl(siteConfig.url, "/speisekarte"),
|
|
49
|
+
menuSections: menuCardMenu.value.map(toSection),
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
useHead(() => ({
|
|
54
|
+
script: [
|
|
55
|
+
{
|
|
56
|
+
key: "jsonld-restaurant",
|
|
57
|
+
type: "application/ld+json",
|
|
58
|
+
innerHTML: JSON.stringify(schema.value),
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
return { schema };
|
|
64
|
+
}
|
|
@@ -1,25 +1,54 @@
|
|
|
1
|
-
import { ref, onMounted, type Ref } from "vue";
|
|
1
|
+
import { ref, onMounted, onBeforeUnmount, type Ref } from "vue";
|
|
2
2
|
|
|
3
3
|
export interface ScrollAnimationOptions {
|
|
4
4
|
threshold?: number;
|
|
5
5
|
rootMargin?: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Reveal-on-scroll state for a section.
|
|
10
|
+
*
|
|
11
|
+
* The content is visible in the server-rendered HTML and on the client's
|
|
12
|
+
* first render, so crawlers, no-JS visitors and slow devices see it, and
|
|
13
|
+
* hydration matches (#250). Only after mount, and only for elements that
|
|
14
|
+
* are not in the viewport yet, `isHidden` becomes true; the element is
|
|
15
|
+
* revealed again when it scrolls into view. Users who prefer reduced
|
|
16
|
+
* motion never get the hidden state.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Everything above the viewport counts as "in view": a section skipped by a
|
|
20
|
+
* jump (anchor link, End key, restored scroll position) must not stay hidden.
|
|
21
|
+
*/
|
|
22
|
+
export const ABOVE_VIEWPORT_MARGIN = "100000px";
|
|
23
|
+
|
|
8
24
|
export function useScrollAnimation(options: ScrollAnimationOptions = {}) {
|
|
9
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
threshold = 0.1,
|
|
27
|
+
rootMargin = `${ABOVE_VIEWPORT_MARGIN} 0px -100px 0px`,
|
|
28
|
+
} = options;
|
|
10
29
|
|
|
11
|
-
const
|
|
30
|
+
const isHidden = ref(false);
|
|
12
31
|
const elementRef: Ref<HTMLElement | null> = ref(null);
|
|
32
|
+
let observer: IntersectionObserver | undefined;
|
|
13
33
|
|
|
14
34
|
onMounted(() => {
|
|
15
|
-
if (
|
|
35
|
+
if (
|
|
36
|
+
!elementRef.value ||
|
|
37
|
+
typeof IntersectionObserver === "undefined" ||
|
|
38
|
+
window.matchMedia?.("(prefers-reduced-motion: reduce)").matches
|
|
39
|
+
) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
16
42
|
|
|
17
|
-
|
|
43
|
+
observer = new IntersectionObserver(
|
|
18
44
|
(entries) => {
|
|
19
45
|
entries.forEach((entry) => {
|
|
20
46
|
if (entry.isIntersecting) {
|
|
21
|
-
|
|
22
|
-
|
|
47
|
+
// Already in view on the first check: stays visible, no animation.
|
|
48
|
+
isHidden.value = false;
|
|
49
|
+
observer?.unobserve(entry.target);
|
|
50
|
+
} else {
|
|
51
|
+
isHidden.value = true;
|
|
23
52
|
}
|
|
24
53
|
});
|
|
25
54
|
},
|
|
@@ -32,8 +61,10 @@ export function useScrollAnimation(options: ScrollAnimationOptions = {}) {
|
|
|
32
61
|
observer.observe(elementRef.value);
|
|
33
62
|
});
|
|
34
63
|
|
|
64
|
+
onBeforeUnmount(() => observer?.disconnect());
|
|
65
|
+
|
|
35
66
|
return {
|
|
36
|
-
|
|
67
|
+
isHidden,
|
|
37
68
|
elementRef,
|
|
38
69
|
};
|
|
39
70
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Reports a site search to Matomo once its results are settled, once per
|
|
6
|
+
* search term.
|
|
7
|
+
*
|
|
8
|
+
* Runs immediately on the client so a page loaded directly (results already
|
|
9
|
+
* in the SSR payload, so `elements` never changes) is tracked too (#296).
|
|
10
|
+
* Sorting changes re-fetch the same term and are not reported again.
|
|
11
|
+
*/
|
|
12
|
+
export function useSearchTracking(
|
|
13
|
+
query: Ref<string>,
|
|
14
|
+
elements: Ref<Schemas["Product"][]>,
|
|
15
|
+
showSkeleton: Ref<boolean>,
|
|
16
|
+
) {
|
|
17
|
+
const { trackSearch } = useTrackEvent();
|
|
18
|
+
let lastTrackedTerm: string | null = null;
|
|
19
|
+
|
|
20
|
+
watch(
|
|
21
|
+
[elements, showSkeleton],
|
|
22
|
+
([products, skeleton]) => {
|
|
23
|
+
const term = query.value;
|
|
24
|
+
if (!term || skeleton || term === lastTrackedTerm) return;
|
|
25
|
+
lastTrackedTerm = term;
|
|
26
|
+
trackSearch(
|
|
27
|
+
term,
|
|
28
|
+
products.map((product) => product.productNumber),
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
{ immediate: import.meta.client },
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Schemas } from "#shopware";
|
|
2
|
+
import { resolveSeoPath } from "~/utils/seoPath";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolves the current route against the backend SEO URLs. Throws a 404 if
|
|
6
|
+
* nothing matches and redirects (301) to the SEO URL if the visited path is
|
|
7
|
+
* only an alias of it: missing or extra trailing slash (#291) or different
|
|
8
|
+
* casing (#244).
|
|
9
|
+
*/
|
|
10
|
+
export async function useSeoUrlRoute() {
|
|
11
|
+
const { resolvePath } = useNavigationSearch();
|
|
12
|
+
const route = useRoute();
|
|
13
|
+
const routePath = route.path;
|
|
14
|
+
|
|
15
|
+
const { data, error } = await useAsyncData(
|
|
16
|
+
`cmsResponse${routePath}`,
|
|
17
|
+
async () => {
|
|
18
|
+
// For client links if the history state contains seo url information we can omit the api call
|
|
19
|
+
if (import.meta.client && history.state?.routeName) {
|
|
20
|
+
return {
|
|
21
|
+
seoUrl: {
|
|
22
|
+
routeName: history.state.routeName,
|
|
23
|
+
foreignKey: history.state.foreignKey,
|
|
24
|
+
} as Schemas["SeoUrl"],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { match, redirectPath } = await resolveSeoPath(
|
|
29
|
+
routePath,
|
|
30
|
+
resolvePath,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (!match?.foreignKey) {
|
|
34
|
+
throw createError({
|
|
35
|
+
statusCode: 404,
|
|
36
|
+
statusMessage: `No data fetched from API for ${routePath}`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { seoUrl: match, redirectPath };
|
|
41
|
+
},
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
if (error.value) {
|
|
45
|
+
throw error.value;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (data.value?.redirectPath) {
|
|
49
|
+
await navigateTo(
|
|
50
|
+
{ path: data.value.redirectPath, query: route.query },
|
|
51
|
+
{ redirectCode: 301, replace: true },
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
seoUrl: computed(() => data.value?.seoUrl),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { computed, ref, type Ref } from "vue";
|
|
2
|
+
|
|
3
|
+
export const SORTING_PLACEHOLDER = "Sortieren";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sorting select state for a listing that follows the listing data.
|
|
7
|
+
*
|
|
8
|
+
* The listing resolves after setup on the server, so a value snapshotted at
|
|
9
|
+
* setup renders the placeholder there while the client (payload present)
|
|
10
|
+
* renders the actual sorting: a hydration mismatch (#239, #295). The user's
|
|
11
|
+
* choice is kept as an override; setting the placeholder clears it, so the
|
|
12
|
+
* select follows the listing data again (e.g. after a new search or filter).
|
|
13
|
+
*/
|
|
14
|
+
export function useSortingSelection(
|
|
15
|
+
currentSortingOrder: Ref<string | undefined>,
|
|
16
|
+
) {
|
|
17
|
+
const sortingOverride = ref<string | null>(null);
|
|
18
|
+
|
|
19
|
+
const currentSorting = computed<string>({
|
|
20
|
+
get: () =>
|
|
21
|
+
sortingOverride.value ?? currentSortingOrder.value ?? SORTING_PLACEHOLDER,
|
|
22
|
+
set: (value) => {
|
|
23
|
+
sortingOverride.value = value === SORTING_PLACEHOLDER ? null : value;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return { currentSorting };
|
|
28
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useIntervalFn } from "@vueuse/core";
|
|
2
|
+
|
|
3
|
+
export type StoreStatus =
|
|
4
|
+
| { open: true; closesAt: string }
|
|
5
|
+
| { open: false; nextOpening: string | null };
|
|
6
|
+
|
|
7
|
+
const formatTime = (date: Date) =>
|
|
8
|
+
`${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether the store is open right now, with the closing time of the current
|
|
12
|
+
* interval or the next opening. `null` until business hours and holidays are
|
|
13
|
+
* loaded. Client only: the browser's clock and time zone decide, the server's
|
|
14
|
+
* would not match the shop's (#275).
|
|
15
|
+
*/
|
|
16
|
+
export function useStoreStatus() {
|
|
17
|
+
const {
|
|
18
|
+
businessHours,
|
|
19
|
+
getServiceIntervals,
|
|
20
|
+
isStoreOpen,
|
|
21
|
+
getNextOpeningTime,
|
|
22
|
+
} = useBusinessHours();
|
|
23
|
+
const { holidays, isClosedHoliday } = useHolidays();
|
|
24
|
+
|
|
25
|
+
const now = ref(new Date());
|
|
26
|
+
useIntervalFn(() => {
|
|
27
|
+
now.value = new Date();
|
|
28
|
+
}, 60_000);
|
|
29
|
+
|
|
30
|
+
const status = computed<StoreStatus | null>(() => {
|
|
31
|
+
if (!businessHours.value || !holidays.value) return null;
|
|
32
|
+
|
|
33
|
+
const current = now.value;
|
|
34
|
+
if (isStoreOpen(current, isClosedHoliday)) {
|
|
35
|
+
const interval = getServiceIntervals(current).find(
|
|
36
|
+
({ start, end }) => current >= start && current <= end,
|
|
37
|
+
);
|
|
38
|
+
return { open: true, closesAt: formatTime(interval?.end ?? current) };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
open: false,
|
|
43
|
+
nextOpening: getNextOpeningTime(now, isClosedHoliday),
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return { status };
|
|
48
|
+
}
|
|
@@ -1,23 +1,43 @@
|
|
|
1
1
|
import type { Schemas } from "#shopware";
|
|
2
2
|
|
|
3
|
+
type MatomoWindow = Window & { _paq?: unknown[][] };
|
|
4
|
+
|
|
3
5
|
export function useTrackEvent() {
|
|
4
|
-
const {
|
|
6
|
+
const { enabled } = useMatomoConfig();
|
|
7
|
+
|
|
8
|
+
// Commands go into Matomo's `_paq` queue; matomo.js processes what was
|
|
9
|
+
// pushed before it loaded, so tracking does not depend on the script (which
|
|
10
|
+
// `plugins/matomo.ts` loads after `onNuxtReady`, #314). Tracking is a no-op
|
|
11
|
+
// when Matomo is not configured (#294).
|
|
12
|
+
function push(command: unknown[]) {
|
|
13
|
+
if (!enabled || import.meta.server) return;
|
|
14
|
+
const matomoWindow = window as MatomoWindow;
|
|
15
|
+
(matomoWindow._paq ??= []).push(command);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Page views are pushed by `plugins/matomo.ts` (initial page and every
|
|
19
|
+
// `page:finish`), not by the registry's page watcher.
|
|
20
|
+
function trackPageView(path: string) {
|
|
21
|
+
push(["setCustomUrl", path]);
|
|
22
|
+
push(["setDocumentTitle", document.title]);
|
|
23
|
+
push(["trackPageView"]);
|
|
24
|
+
}
|
|
5
25
|
|
|
6
26
|
function trackProductView(product: Schemas["Product"]) {
|
|
7
|
-
|
|
27
|
+
push([
|
|
8
28
|
"setEcommerceView",
|
|
9
29
|
product.productNumber,
|
|
10
30
|
product.translated.name ?? product.name,
|
|
11
31
|
product.seoCategory?.name ?? false,
|
|
12
32
|
product.calculatedPrice.unitPrice,
|
|
13
33
|
]);
|
|
14
|
-
|
|
34
|
+
push(["trackPageView", product.productNumber]);
|
|
15
35
|
}
|
|
16
36
|
|
|
17
37
|
function trackOrder(order: Schemas["Order"]) {
|
|
18
38
|
order.lineItems?.forEach((item) => {
|
|
19
39
|
if (item.type === "container") return;
|
|
20
|
-
|
|
40
|
+
push([
|
|
21
41
|
"addEcommerceItem",
|
|
22
42
|
item.product?.productNumber ?? item.id,
|
|
23
43
|
item.label,
|
|
@@ -27,37 +47,23 @@ export function useTrackEvent() {
|
|
|
27
47
|
]);
|
|
28
48
|
});
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
"trackEcommerceOrder",
|
|
32
|
-
order.orderNumber,
|
|
33
|
-
order.price.totalPrice,
|
|
34
|
-
]);
|
|
50
|
+
push(["trackEcommerceOrder", order.orderNumber, order.price.totalPrice]);
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
function trackAddToWishlist(product: Schemas["Product"]) {
|
|
38
|
-
|
|
39
|
-
"trackEvent",
|
|
40
|
-
"Product",
|
|
41
|
-
"AddToWishlist",
|
|
42
|
-
product.productNumber,
|
|
43
|
-
]);
|
|
54
|
+
push(["trackEvent", "Product", "AddToWishlist", product.productNumber]);
|
|
44
55
|
}
|
|
45
56
|
|
|
46
57
|
function trackAddToCart(product: Schemas["Product"], quantity: number) {
|
|
47
|
-
|
|
48
|
-
"trackEvent",
|
|
49
|
-
"Cart",
|
|
50
|
-
"AddToCart",
|
|
51
|
-
product.productNumber,
|
|
52
|
-
quantity,
|
|
53
|
-
]);
|
|
58
|
+
push(["trackEvent", "Cart", "AddToCart", product.productNumber, quantity]);
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
function trackSearch(term: string, productNumbers: string[]) {
|
|
57
|
-
|
|
62
|
+
push(["trackSiteSearch", term, false, productNumbers.length]);
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
return {
|
|
66
|
+
trackPageView,
|
|
61
67
|
trackProductView,
|
|
62
68
|
trackOrder,
|
|
63
69
|
trackAddToWishlist,
|
package/app/pages/[...all].vue
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
const route = useRoute();
|
|
3
|
+
// Server route instead of queryCollection(): keeps the SQLite WASM client
|
|
4
|
+
// out of client-side navigations (#314).
|
|
3
5
|
const { data: page, error } = await useAsyncData(
|
|
4
6
|
`landingpages-${route.path}`,
|
|
5
|
-
() => {
|
|
6
|
-
return queryCollection("landingpages").path(route.path).first();
|
|
7
|
-
},
|
|
7
|
+
() => $fetch("/api/content/page", { query: { path: route.path } }),
|
|
8
8
|
);
|
|
9
9
|
|
|
10
10
|
if (error.value || !page.value) {
|
|
@@ -15,7 +15,7 @@ if (error.value || !page.value) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
usePageSeo({
|
|
19
19
|
title: page.value?.title,
|
|
20
20
|
description: page.value?.description,
|
|
21
21
|
});
|
package/app/pages/anmelden.vue
CHANGED
|
@@ -3,11 +3,11 @@ import { useOrderPayment, useOrderDetails } from "@shopware/composables";
|
|
|
3
3
|
import type { Schemas } from "#shopware";
|
|
4
4
|
|
|
5
5
|
const {
|
|
6
|
-
public: {
|
|
6
|
+
public: { storeUrl },
|
|
7
7
|
} = useRuntimeConfig();
|
|
8
8
|
|
|
9
9
|
useSeoMeta({
|
|
10
|
-
title:
|
|
10
|
+
title: "Zahlung fehlgeschlagen",
|
|
11
11
|
robots: "noindex, nofollow",
|
|
12
12
|
});
|
|
13
13
|
|