@shopbite-de/storefront 1.29.0 → 1.31.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 +9 -0
- package/CLAUDE.md +5 -1
- package/app/components/Category/Listing.vue +1 -0
- package/app/components/Home/Faq.vue +58 -0
- package/app/components/Home/Highlights.vue +1 -0
- package/app/components/Product/Card.vue +46 -10
- package/app/components/Product/CardDietBadges.vue +7 -13
- package/app/components/Product/CrossSelling.vue +18 -2
- package/app/components/Product/DeselectIngredient.vue +10 -3
- package/app/components/Product/Detail.vue +33 -2
- package/app/components/Product/QuickView.vue +20 -1
- package/app/composables/useMenuSectionSchema.ts +21 -8
- package/app/composables/useProductCrossSelling.ts +1 -0
- package/app/composables/useProductQuickView.ts +151 -9
- package/app/composables/useRestaurantSchema.ts +40 -3
- package/app/composables/useSeoUrlRoute.ts +50 -5
- package/app/composables/useShareLink.ts +61 -0
- package/app/composables/useTopSellers.ts +4 -1
- package/app/composables/useTrackEvent.ts +19 -0
- package/app/pages/[...all].vue +38 -10
- package/app/pages/index.vue +7 -0
- package/app/types/Association.d.ts +2 -0
- package/app/utils/product.ts +28 -0
- package/app/utils/productUrl.ts +87 -0
- package/app/utils/schema.ts +82 -1
- package/app/utils/seo.ts +13 -0
- package/app/utils/seoPath.ts +13 -2
- package/content/index.yml +18 -0
- package/content.config.ts +13 -0
- package/docs/notes/2026-10-05-issue-289-product-deep-links.md +28 -0
- package/docs/notes/2026-10-05-issue-400-menu-item-ingredients-diet.md +18 -0
- package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +21 -0
- package/docs/notes/2026-10-05-issue-402-llms-txt.md +17 -0
- package/docs/notes/2026-10-05-issue-403-ai-crawlers.md +15 -0
- package/docs/notes/2026-10-05-issue-404-faq.md +21 -0
- package/docs/notes/2026-10-05-issue-411-quick-view-share.md +22 -0
- package/docs/notes/2026-10-06-old-seo-url-redirect.md +30 -0
- package/nuxt.config.ts +20 -0
- package/package.json +3 -3
- package/server/api/listing/[categoryId].get.ts +3 -0
- package/server/api/product/[productId]/cross-selling.get.ts +2 -1
- package/server/plugins/ai-crawlers.ts +27 -0
- package/server/routes/llms.txt.ts +213 -0
- package/server/utils/aiCrawlers.ts +79 -0
- package/server/utils/llmsTxt.ts +207 -0
- package/test/nuxt/HomeFaq.test.ts +34 -0
- package/test/nuxt/ProductCrossSelling.test.ts +20 -0
- package/test/nuxt/ProductDeselectIngredient.test.ts +34 -0
- package/test/nuxt/useSeoUrlRoute.test.ts +88 -5
- package/test/nuxt/useShareLink.test.ts +103 -0
- package/test/nuxt/useTrackEvent.test.ts +16 -0
- package/test/unit/aiCrawlers.spec.ts +48 -0
- package/test/unit/llmsTxt.spec.ts +149 -0
- package/test/unit/product.spec.ts +20 -0
- package/test/unit/productUrl.spec.ts +90 -0
- package/test/unit/schema.spec.ts +123 -0
- package/test/unit/seo.spec.ts +13 -0
- package/test/unit/seoPath.spec.ts +45 -0
- package/app/pages/c/[...all].vue +0 -20
- package/app/pages/speisekarte/[...all].vue +0 -20
|
@@ -1,26 +1,41 @@
|
|
|
1
1
|
import type { Schemas } from "#shopware";
|
|
2
2
|
import type { LocationQueryRaw } from "vue-router";
|
|
3
|
+
import {
|
|
4
|
+
EXTRAS_PARAM,
|
|
5
|
+
PRODUCT_QUICK_VIEW_PARAM,
|
|
6
|
+
WITHOUT_INGREDIENTS_PARAM,
|
|
7
|
+
parseListParam,
|
|
8
|
+
withQuickViewConfiguration,
|
|
9
|
+
type QuickViewConfiguration,
|
|
10
|
+
} from "../utils/productUrl";
|
|
3
11
|
|
|
4
|
-
|
|
5
|
-
|
|
12
|
+
// Numbers the open quick view switched to itself (variant switch, #411):
|
|
13
|
+
// the URL follows the selection, but the drawer keeps its product.
|
|
14
|
+
const SWITCHED_NUMBERS_KEY = "quick-view-switched-numbers";
|
|
6
15
|
|
|
7
16
|
/**
|
|
8
17
|
* The product quick view (options, quantity, add to cart) is a drawer over
|
|
9
18
|
* the listing whose state lives in the URL: `?produkt=<productNumber>` opens
|
|
10
19
|
* it, so a product can be linked and the back button closes it (#325).
|
|
20
|
+
* A number that is not in the list (a variant, #289) is loaded from the
|
|
21
|
+
* Store API; the quick view then opens with the variant's options selected.
|
|
22
|
+
* The configuration (variant, deselected ingredients, extras) is kept in the
|
|
23
|
+
* URL as well, see useQuickViewConfiguration (#411).
|
|
11
24
|
*/
|
|
12
25
|
export function useProductQuickView(
|
|
13
26
|
products: MaybeRefOrGetter<Schemas["Product"][]>,
|
|
14
27
|
) {
|
|
15
28
|
const route = useRoute();
|
|
16
29
|
const router = useRouter();
|
|
30
|
+
const { apiClient } = useShopwareContext();
|
|
31
|
+
const switchedNumbers = useState<string[]>(SWITCHED_NUMBERS_KEY, () => []);
|
|
17
32
|
|
|
18
33
|
const requestedNumber = computed(() => {
|
|
19
34
|
const value = route.query[PRODUCT_QUICK_VIEW_PARAM];
|
|
20
35
|
return typeof value === "string" && value !== "" ? value : undefined;
|
|
21
36
|
});
|
|
22
37
|
|
|
23
|
-
const
|
|
38
|
+
const listed = computed(() =>
|
|
24
39
|
requestedNumber.value
|
|
25
40
|
? toValue(products).find(
|
|
26
41
|
(candidate) => candidate.productNumber === requestedNumber.value,
|
|
@@ -28,6 +43,51 @@ export function useProductQuickView(
|
|
|
28
43
|
: undefined,
|
|
29
44
|
);
|
|
30
45
|
|
|
46
|
+
const loaded = shallowRef<Schemas["Product"]>();
|
|
47
|
+
watch(
|
|
48
|
+
[requestedNumber, () => toValue(products).length],
|
|
49
|
+
async ([number, count]) => {
|
|
50
|
+
// Only in the browser (the drawer is client-only) and once the list
|
|
51
|
+
// is there, so a listed product never costs a request.
|
|
52
|
+
if (!import.meta.client || !number || count === 0 || listed.value) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (switchedNumbers.value.includes(number)) return;
|
|
56
|
+
if (loaded.value?.productNumber === number) return;
|
|
57
|
+
const result = await loadProductByNumber(apiClient, number);
|
|
58
|
+
if (requestedNumber.value === number) loaded.value = result;
|
|
59
|
+
},
|
|
60
|
+
{ immediate: true },
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const resolved = computed(
|
|
64
|
+
() =>
|
|
65
|
+
listed.value ??
|
|
66
|
+
(loaded.value && loaded.value.productNumber === requestedNumber.value
|
|
67
|
+
? loaded.value
|
|
68
|
+
: undefined),
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const opened = shallowRef<Schemas["Product"]>();
|
|
72
|
+
const product = computed(() => {
|
|
73
|
+
const number = requestedNumber.value;
|
|
74
|
+
if (!number) return undefined;
|
|
75
|
+
if (opened.value && switchedNumbers.value.includes(number)) {
|
|
76
|
+
return opened.value;
|
|
77
|
+
}
|
|
78
|
+
return resolved.value;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
watch(
|
|
82
|
+
product,
|
|
83
|
+
(value) => {
|
|
84
|
+
if (value === opened.value) return;
|
|
85
|
+
opened.value = value;
|
|
86
|
+
switchedNumbers.value = [];
|
|
87
|
+
},
|
|
88
|
+
{ immediate: true },
|
|
89
|
+
);
|
|
90
|
+
|
|
31
91
|
// The drawer is created on first use, not with the page (#314).
|
|
32
92
|
const mounted = ref(false);
|
|
33
93
|
watch(
|
|
@@ -48,18 +108,100 @@ export function useProductQuickView(
|
|
|
48
108
|
function show(candidate: Schemas["Product"]) {
|
|
49
109
|
if (requestedNumber.value === candidate.productNumber) return;
|
|
50
110
|
router.push({
|
|
51
|
-
query: {
|
|
52
|
-
|
|
53
|
-
[
|
|
54
|
-
|
|
111
|
+
query: withQuickViewConfiguration(route.query, {
|
|
112
|
+
productNumber: candidate.productNumber,
|
|
113
|
+
without: [],
|
|
114
|
+
extras: [],
|
|
115
|
+
}) as LocationQueryRaw,
|
|
55
116
|
});
|
|
56
117
|
}
|
|
57
118
|
|
|
58
119
|
function close() {
|
|
59
120
|
if (!requestedNumber.value) return;
|
|
60
|
-
|
|
61
|
-
|
|
121
|
+
router.replace({
|
|
122
|
+
query: withQuickViewConfiguration(
|
|
123
|
+
route.query,
|
|
124
|
+
undefined,
|
|
125
|
+
) as LocationQueryRaw,
|
|
126
|
+
});
|
|
62
127
|
}
|
|
63
128
|
|
|
64
129
|
return { product, open, mounted, show, close };
|
|
65
130
|
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The configuration of the open quick view in the URL (#411): `initial` is
|
|
134
|
+
* what the URL carries (the detail components read it once, when a product
|
|
135
|
+
* opens), `update` writes the current selection back (replace, no history
|
|
136
|
+
* entry).
|
|
137
|
+
*/
|
|
138
|
+
export function useQuickViewConfiguration() {
|
|
139
|
+
const route = useRoute();
|
|
140
|
+
const router = useRouter();
|
|
141
|
+
const switchedNumbers = useState<string[]>(SWITCHED_NUMBERS_KEY, () => []);
|
|
142
|
+
|
|
143
|
+
const initial = computed(() => ({
|
|
144
|
+
without: parseListParam(route.query[WITHOUT_INGREDIENTS_PARAM]),
|
|
145
|
+
extras: parseListParam(route.query[EXTRAS_PARAM]),
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
function update(configuration: QuickViewConfiguration) {
|
|
149
|
+
// Closed meanwhile (add to cart, back button): nothing to write.
|
|
150
|
+
if (!route.query[PRODUCT_QUICK_VIEW_PARAM]) return;
|
|
151
|
+
if (!switchedNumbers.value.includes(configuration.productNumber)) {
|
|
152
|
+
switchedNumbers.value = [
|
|
153
|
+
...switchedNumbers.value,
|
|
154
|
+
configuration.productNumber,
|
|
155
|
+
];
|
|
156
|
+
}
|
|
157
|
+
router.replace({
|
|
158
|
+
query: withQuickViewConfiguration(
|
|
159
|
+
route.query,
|
|
160
|
+
configuration,
|
|
161
|
+
) as LocationQueryRaw,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return { initial, update };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** A product (usually a variant) by its number, as the quick view needs it. */
|
|
169
|
+
async function loadProductByNumber(
|
|
170
|
+
apiClient: ReturnType<typeof useShopwareContext>["apiClient"],
|
|
171
|
+
productNumber: string,
|
|
172
|
+
): Promise<Schemas["Product"] | undefined> {
|
|
173
|
+
try {
|
|
174
|
+
const result = await apiClient.invoke("readProduct post /product", {
|
|
175
|
+
// Variants inherit name, cover and properties from their parent.
|
|
176
|
+
|
|
177
|
+
// @ts-expect-error sw-inheritance is missing from the generated header type
|
|
178
|
+
headers: { "sw-inheritance": "true" },
|
|
179
|
+
body: {
|
|
180
|
+
filter: [
|
|
181
|
+
{ type: "equals", field: "productNumber", value: productNumber },
|
|
182
|
+
],
|
|
183
|
+
limit: 1,
|
|
184
|
+
includes: {
|
|
185
|
+
product: [
|
|
186
|
+
"id",
|
|
187
|
+
"parentId",
|
|
188
|
+
"productNumber",
|
|
189
|
+
"name",
|
|
190
|
+
"translated",
|
|
191
|
+
"description",
|
|
192
|
+
"sortedProperties",
|
|
193
|
+
],
|
|
194
|
+
property_group: ["id", "name", "translated", "options"],
|
|
195
|
+
property_group_option: ["id", "name", "translated"],
|
|
196
|
+
},
|
|
197
|
+
associations: {
|
|
198
|
+
properties: { associations: { group: {} } },
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
return result.data.elements?.[0];
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error("[useProductQuickView] product not found", error);
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
2
2
|
import { buildRestaurantSchema, type MenuSectionInfo } from "../utils/schema";
|
|
3
|
-
import { toAbsoluteUrl } from "../utils/seo";
|
|
3
|
+
import { splitList, toAbsoluteUrl } from "../utils/seo";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `Restaurant` JSON-LD for the home page (#272): shop data from
|
|
7
7
|
* `runtimeConfig.public.site`, weekly hours and closing days from the ShopBite
|
|
8
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.
|
|
9
|
+
* prefetched on the server so the schema is part of the HTML. Ordering,
|
|
10
|
+
* delivery areas and payment methods (#401) tell AI assistants and search
|
|
11
|
+
* engines how to order.
|
|
10
12
|
*/
|
|
11
13
|
export function useRestaurantSchema() {
|
|
12
14
|
const { site } = useRuntimeConfig().public;
|
|
@@ -14,6 +16,33 @@ export function useRestaurantSchema() {
|
|
|
14
16
|
const { businessHours, refresh: refreshBusinessHours } = useBusinessHours();
|
|
15
17
|
const { holidays, refresh: refreshHolidays } = useHolidays();
|
|
16
18
|
const { menuCardMenu } = useNavigation(true);
|
|
19
|
+
const { isCheckoutEnabled } = useShopBiteConfig();
|
|
20
|
+
const { currencyCode } = useCommercePrice();
|
|
21
|
+
const { apiClient } = useShopwareContext();
|
|
22
|
+
|
|
23
|
+
const { data: paymentMethods } = useAsyncData(
|
|
24
|
+
"restaurant-schema-payment-methods",
|
|
25
|
+
async () => {
|
|
26
|
+
try {
|
|
27
|
+
const { data } = await apiClient.invoke(
|
|
28
|
+
"readPaymentMethod post /payment-method",
|
|
29
|
+
{
|
|
30
|
+
body: {
|
|
31
|
+
onlyAvailable: true,
|
|
32
|
+
includes: { payment_method: ["name", "translated"] },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
return (data.elements ?? []).map(
|
|
37
|
+
(method) => method.translated?.name ?? method.name,
|
|
38
|
+
);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error("Failed to load payment methods", error);
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{ default: () => [] },
|
|
45
|
+
);
|
|
17
46
|
|
|
18
47
|
onServerPrefetch(() =>
|
|
19
48
|
Promise.all([refreshBusinessHours(), refreshHolidays()]),
|
|
@@ -28,6 +57,8 @@ export function useRestaurantSchema() {
|
|
|
28
57
|
sections: item.children?.map(toSection),
|
|
29
58
|
});
|
|
30
59
|
|
|
60
|
+
const menuUrl = toAbsoluteUrl(siteConfig.url, "/speisekarte");
|
|
61
|
+
|
|
31
62
|
const schema = computed(() =>
|
|
32
63
|
buildRestaurantSchema({
|
|
33
64
|
site: {
|
|
@@ -42,11 +73,17 @@ export function useRestaurantSchema() {
|
|
|
42
73
|
priceRange: site.priceRange,
|
|
43
74
|
googleBusinessProfileUrl: site.googleBusinessProfileUrl,
|
|
44
75
|
address: site.address,
|
|
76
|
+
deliveryAreas: splitList(site.deliveryAreas),
|
|
77
|
+
geo: site.geo,
|
|
78
|
+
acceptsReservations: site.acceptsReservations,
|
|
45
79
|
},
|
|
46
80
|
businessHours: businessHours.value ?? [],
|
|
47
81
|
holidays: holidays.value ?? [],
|
|
48
|
-
menuUrl
|
|
82
|
+
menuUrl,
|
|
49
83
|
menuSections: menuCardMenu.value.map(toSection),
|
|
84
|
+
orderUrl: isCheckoutEnabled.value ? menuUrl : undefined,
|
|
85
|
+
paymentMethods: paymentMethods.value,
|
|
86
|
+
currency: currencyCode.value,
|
|
50
87
|
}),
|
|
51
88
|
);
|
|
52
89
|
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { Schemas } from "#shopware";
|
|
2
2
|
import { resolveSeoPath } from "~/utils/seoPath";
|
|
3
3
|
|
|
4
|
+
const CATEGORY_ROUTE = "frontend.navigation.page";
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
|
-
* Resolves the current route against the backend SEO URLs. Throws a
|
|
6
|
-
* nothing matches and redirects (301) to the SEO URL if the visited
|
|
7
|
-
* only an alias of it: missing or extra trailing slash (#291)
|
|
8
|
-
* casing (#244).
|
|
7
|
+
* Resolves the current route against the backend category SEO URLs. Throws a
|
|
8
|
+
* 404 if nothing matches and redirects (301) to the SEO URL if the visited
|
|
9
|
+
* path is only an alias of it: missing or extra trailing slash (#291),
|
|
10
|
+
* different casing (#244) or an old SEO URL of the same category. Product SEO
|
|
11
|
+
* URLs have no page (#289) and count as no match.
|
|
9
12
|
*/
|
|
10
13
|
export async function useSeoUrlRoute() {
|
|
11
14
|
const { resolvePath } = useNavigationSearch();
|
|
15
|
+
const { apiClient } = useShopwareContext();
|
|
12
16
|
const route = useRoute();
|
|
13
17
|
const routePath = route.path;
|
|
14
18
|
|
|
@@ -27,7 +31,8 @@ export async function useSeoUrlRoute() {
|
|
|
27
31
|
|
|
28
32
|
const { match, redirectPath } = await resolveSeoPath(
|
|
29
33
|
routePath,
|
|
30
|
-
|
|
34
|
+
resolveCategoryPath,
|
|
35
|
+
resolveOldPath,
|
|
31
36
|
);
|
|
32
37
|
|
|
33
38
|
if (!match?.foreignKey) {
|
|
@@ -52,6 +57,46 @@ export async function useSeoUrlRoute() {
|
|
|
52
57
|
);
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
async function resolveCategoryPath(
|
|
61
|
+
path: string,
|
|
62
|
+
): Promise<Schemas["SeoUrl"] | null> {
|
|
63
|
+
const match = await resolvePath(path);
|
|
64
|
+
return match?.routeName === CATEGORY_ROUTE ? match : null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The current SEO URL of the category an old SEO URL belonged to. Shopware
|
|
69
|
+
* keeps old SEO URLs with `isCanonical: null`; the Store API only returns
|
|
70
|
+
* them when the criteria filter on `isCanonical` themselves.
|
|
71
|
+
*/
|
|
72
|
+
async function resolveOldPath(
|
|
73
|
+
path: string,
|
|
74
|
+
): Promise<Schemas["SeoUrl"] | null> {
|
|
75
|
+
const old = await findSeoUrl([
|
|
76
|
+
{ type: "equals", field: "seoPathInfo", value: path.substring(1) },
|
|
77
|
+
{ type: "equals", field: "routeName", value: CATEGORY_ROUTE },
|
|
78
|
+
{ type: "equals", field: "isCanonical", value: null },
|
|
79
|
+
]);
|
|
80
|
+
if (!old) return null;
|
|
81
|
+
|
|
82
|
+
return findSeoUrl([
|
|
83
|
+
{ type: "equals", field: "foreignKey", value: old.foreignKey },
|
|
84
|
+
{ type: "equals", field: "routeName", value: CATEGORY_ROUTE },
|
|
85
|
+
{ type: "equals", field: "languageId", value: old.languageId },
|
|
86
|
+
{ type: "equals", field: "isCanonical", value: true },
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function findSeoUrl(
|
|
91
|
+
filter: { type: "equals"; field: string; value: string | boolean | null }[],
|
|
92
|
+
): Promise<Schemas["SeoUrl"] | null> {
|
|
93
|
+
const { data } = await apiClient.invoke("readSeoUrl post /seo-url", {
|
|
94
|
+
body: { limit: 1, filter },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return data.elements?.[0] ?? null;
|
|
98
|
+
}
|
|
99
|
+
|
|
55
100
|
return {
|
|
56
101
|
seoUrl: computed(() => data.value?.seoUrl),
|
|
57
102
|
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shares the current page (#411): the native share sheet where the browser
|
|
3
|
+
* has one (phones: WhatsApp, messages …), otherwise the link is copied and
|
|
4
|
+
* a toast confirms it. `canShare` is false during SSR and the first render,
|
|
5
|
+
* so the button's icon does not cause a hydration mismatch.
|
|
6
|
+
*
|
|
7
|
+
* With a `productNumber`, a completed share or copy is tracked in Matomo
|
|
8
|
+
* together with the shared path (`useTrackEvent().trackShare`).
|
|
9
|
+
*/
|
|
10
|
+
export function useShareLink() {
|
|
11
|
+
const toast = useToast();
|
|
12
|
+
const { trackShare } = useTrackEvent();
|
|
13
|
+
const canShare = ref(false);
|
|
14
|
+
|
|
15
|
+
onMounted(() => {
|
|
16
|
+
canShare.value = typeof navigator.share === "function";
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
async function share({
|
|
20
|
+
title,
|
|
21
|
+
productNumber,
|
|
22
|
+
}: { title?: string; productNumber?: string } = {}) {
|
|
23
|
+
const url = window.location.href;
|
|
24
|
+
const { pathname, search, hash } = window.location;
|
|
25
|
+
const track = (method: "share" | "copy") => {
|
|
26
|
+
if (productNumber)
|
|
27
|
+
trackShare(method, productNumber, pathname + search + hash);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
if (canShare.value) {
|
|
31
|
+
try {
|
|
32
|
+
await navigator.share({ title, url });
|
|
33
|
+
track("share");
|
|
34
|
+
return;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
// Closing the share sheet is no error.
|
|
37
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await navigator.clipboard.writeText(url);
|
|
45
|
+
track("copy");
|
|
46
|
+
toast.add({
|
|
47
|
+
title: "Link kopiert",
|
|
48
|
+
icon: "i-lucide-check",
|
|
49
|
+
color: "success",
|
|
50
|
+
});
|
|
51
|
+
} catch {
|
|
52
|
+
toast.add({
|
|
53
|
+
title: "Link konnte nicht kopiert werden",
|
|
54
|
+
description: url,
|
|
55
|
+
color: "error",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { share, canShare };
|
|
61
|
+
}
|
|
@@ -14,7 +14,7 @@ export function useTopSellers(): useTopSellersReturn {
|
|
|
14
14
|
// Variants marked as top sellers inherit name, cover and properties.
|
|
15
15
|
|
|
16
16
|
// @ts-expect-error sw-inheritance is missing from the generated header type
|
|
17
|
-
headers: { "sw-inheritance": "true" },
|
|
17
|
+
headers: { "sw-inheritance": "true", "sw-include-seo-urls": "true" },
|
|
18
18
|
body: {
|
|
19
19
|
filter: [{ type: "equals", field: "markAsTopseller", value: true }],
|
|
20
20
|
limit: TOP_SELLERS_LIMIT,
|
|
@@ -30,7 +30,10 @@ export function useTopSellers(): useTopSellersReturn {
|
|
|
30
30
|
"available",
|
|
31
31
|
"cover",
|
|
32
32
|
"sortedProperties",
|
|
33
|
+
// Card link to the quick view deep link (#289).
|
|
34
|
+
"seoUrls",
|
|
33
35
|
],
|
|
36
|
+
seo_url: ["seoPathInfo", "isCanonical"],
|
|
34
37
|
product_media: ["media"],
|
|
35
38
|
media: ["url", "thumbnails"],
|
|
36
39
|
media_thumbnail: ["width", "url"],
|
|
@@ -64,6 +64,24 @@ export function useTrackEvent() {
|
|
|
64
64
|
push(["trackEvent", "Cart", "UpsellAdd", product.productNumber, quantity]);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
// A shared product link: `Share` for the native share sheet, `CopyLink`
|
|
68
|
+
// for the clipboard. The shared path carries the quick view configuration
|
|
69
|
+
// (`ohne`, `extras`, #411) and becomes the event's page URL; router.replace
|
|
70
|
+
// does not trigger a page view, so the last tracked URL would lack it.
|
|
71
|
+
function trackShare(
|
|
72
|
+
method: "share" | "copy",
|
|
73
|
+
productNumber: string,
|
|
74
|
+
path: string,
|
|
75
|
+
) {
|
|
76
|
+
push(["setCustomUrl", path]);
|
|
77
|
+
push([
|
|
78
|
+
"trackEvent",
|
|
79
|
+
"Product",
|
|
80
|
+
method === "share" ? "Share" : "CopyLink",
|
|
81
|
+
productNumber,
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
|
|
67
85
|
function trackSearch(term: string, productNumbers: string[]) {
|
|
68
86
|
push(["trackSiteSearch", term, false, productNumbers.length]);
|
|
69
87
|
}
|
|
@@ -75,6 +93,7 @@ export function useTrackEvent() {
|
|
|
75
93
|
trackAddToWishlist,
|
|
76
94
|
trackAddToCart,
|
|
77
95
|
trackUpsellAdd,
|
|
96
|
+
trackShare,
|
|
78
97
|
trackSearch,
|
|
79
98
|
};
|
|
80
99
|
}
|
package/app/pages/[...all].vue
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
<script setup>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
3
|
+
|
|
4
|
+
// Every path without a file-based page: Markdown content pages first, then
|
|
5
|
+
// the category SEO URLs of the backend, whatever their prefix (`/c/Pizza/`,
|
|
6
|
+
// `/speisekarte/pizza/`).
|
|
2
7
|
const route = useRoute();
|
|
3
8
|
// Server route instead of queryCollection(): keeps the SQLite WASM client
|
|
4
9
|
// out of client-side navigations (#314).
|
|
@@ -17,18 +22,41 @@ if ((error.value?.statusCode ?? 0) >= 500) {
|
|
|
17
22
|
});
|
|
18
23
|
}
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
let categoryId: Ref<string> | undefined;
|
|
26
|
+
|
|
27
|
+
if (page.value) {
|
|
28
|
+
usePageSeo({
|
|
29
|
+
title: page.value.title,
|
|
30
|
+
description: page.value.description,
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
// Scanner requests (`/wp-login.php`, `/.env`) are no SEO URLs; answer
|
|
34
|
+
// them without asking the backend.
|
|
35
|
+
if (/\.[a-z0-9]+$/i.test(route.path)) {
|
|
36
|
+
throw createNotFoundError(`Page ${route.path} not found!`);
|
|
37
|
+
}
|
|
23
38
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
const { seoUrl } = await useSeoUrlRoute();
|
|
40
|
+
categoryId = useNavigationContext(
|
|
41
|
+
seoUrl as Ref<Schemas["SeoUrl"]>,
|
|
42
|
+
).foreignKey;
|
|
43
|
+
|
|
44
|
+
const { clearBreadcrumbs } = useBreadcrumbs();
|
|
45
|
+
onBeforeRouteLeave(() => {
|
|
46
|
+
clearBreadcrumbs();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
28
49
|
</script>
|
|
29
50
|
|
|
30
51
|
<template>
|
|
31
|
-
<UContainer>
|
|
32
|
-
<ContentRenderer
|
|
52
|
+
<UContainer v-if="page">
|
|
53
|
+
<ContentRenderer :value="page" class="content my-8" />
|
|
33
54
|
</UContainer>
|
|
55
|
+
<div v-else-if="categoryId">
|
|
56
|
+
<!-- the listing layout's category bar, without switching layouts -->
|
|
57
|
+
<div class="sticky top-16 left-0 z-20 w-full backdrop-blur-md rounded-md">
|
|
58
|
+
<NavigationMobileTop />
|
|
59
|
+
</div>
|
|
60
|
+
<CategoryListing :id="categoryId" :key="categoryId" />
|
|
61
|
+
</div>
|
|
34
62
|
</template>
|
package/app/pages/index.vue
CHANGED
|
@@ -92,6 +92,13 @@ useRestaurantSchema();
|
|
|
92
92
|
:images="page.gallery.images"
|
|
93
93
|
:links="page.gallery.links"
|
|
94
94
|
/>
|
|
95
|
+
<HomeFaq
|
|
96
|
+
v-if="page.faq?.items?.length"
|
|
97
|
+
:title="page.faq.title"
|
|
98
|
+
:description="page.faq.description"
|
|
99
|
+
:headline="page.faq.headline"
|
|
100
|
+
:items="page.faq.items"
|
|
101
|
+
/>
|
|
95
102
|
<Cta
|
|
96
103
|
:title="page.cta.title"
|
|
97
104
|
:description="page.cta.description"
|
package/app/utils/product.ts
CHANGED
|
@@ -2,6 +2,11 @@ import type { Schemas } from "#shopware";
|
|
|
2
2
|
|
|
3
3
|
const MAIN_INGREDIENTS_GROUP = "Hauptzutaten";
|
|
4
4
|
|
|
5
|
+
// Property groups whose option "Ja" marks the diet of a product.
|
|
6
|
+
const DIET_GROUPS = { vegetarian: "Vegetarisch", vegan: "Vegan" } as const;
|
|
7
|
+
|
|
8
|
+
export type Diet = keyof typeof DIET_GROUPS;
|
|
9
|
+
|
|
5
10
|
/** `available` is optional in the projection; missing means orderable. */
|
|
6
11
|
export function productIsAvailable(product: Schemas["Product"]): boolean {
|
|
7
12
|
return product.available !== false;
|
|
@@ -29,3 +34,26 @@ export function getMainIngredients(
|
|
|
29
34
|
);
|
|
30
35
|
return group?.options ?? [];
|
|
31
36
|
}
|
|
37
|
+
|
|
38
|
+
/** Whether the product has the option "Ja" in the given property group. */
|
|
39
|
+
export function hasYesOption(
|
|
40
|
+
sortedProperties: Schemas["PropertyGroup"][] | undefined,
|
|
41
|
+
groupName: string,
|
|
42
|
+
): boolean {
|
|
43
|
+
return (
|
|
44
|
+
sortedProperties?.some(
|
|
45
|
+
(group) =>
|
|
46
|
+
group.translated.name === groupName &&
|
|
47
|
+
group.options?.some((option) => option.translated.name === "Ja"),
|
|
48
|
+
) ?? false
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Diets marked on the product via the `Vegetarisch`/`Vegan` groups. */
|
|
53
|
+
export function getDiets(
|
|
54
|
+
sortedProperties: Schemas["PropertyGroup"][] | undefined,
|
|
55
|
+
): Diet[] {
|
|
56
|
+
return (Object.keys(DIET_GROUPS) as Diet[]).filter((diet) =>
|
|
57
|
+
hasYesOption(sortedProperties, DIET_GROUPS[diet]),
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { withLeadingSlash, withQuery } from "ufo";
|
|
2
|
+
|
|
3
|
+
/** Query parameter that holds the product number of the open quick view. */
|
|
4
|
+
export const PRODUCT_QUICK_VIEW_PARAM = "produkt";
|
|
5
|
+
/** Deselected main ingredients by name, comma-separated (#411). */
|
|
6
|
+
export const WITHOUT_INGREDIENTS_PARAM = "ohne";
|
|
7
|
+
/** Selected extras by product number, comma-separated (#411). */
|
|
8
|
+
export const EXTRAS_PARAM = "extras";
|
|
9
|
+
|
|
10
|
+
/** The quick view configuration a link carries. */
|
|
11
|
+
export type QuickViewConfiguration = {
|
|
12
|
+
productNumber: string;
|
|
13
|
+
without: string[];
|
|
14
|
+
extras: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** A comma-separated query value (or repeated parameter) as a list. */
|
|
18
|
+
export function parseListParam(value: unknown): string[] {
|
|
19
|
+
const values = Array.isArray(value) ? value : [value];
|
|
20
|
+
return values
|
|
21
|
+
.filter((entry): entry is string => typeof entry === "string")
|
|
22
|
+
.flatMap((entry) => entry.split(","))
|
|
23
|
+
.map((entry) => entry.trim())
|
|
24
|
+
.filter(Boolean);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The query of a configured quick view: the three parameters replace the
|
|
29
|
+
* old ones, everything else (filters) is kept; empty lists are left out.
|
|
30
|
+
*/
|
|
31
|
+
export function withQuickViewConfiguration(
|
|
32
|
+
query: Record<string, unknown>,
|
|
33
|
+
configuration: QuickViewConfiguration | undefined,
|
|
34
|
+
): Record<string, unknown> {
|
|
35
|
+
const {
|
|
36
|
+
[PRODUCT_QUICK_VIEW_PARAM]: _product,
|
|
37
|
+
[WITHOUT_INGREDIENTS_PARAM]: _without,
|
|
38
|
+
[EXTRAS_PARAM]: _extras,
|
|
39
|
+
...rest
|
|
40
|
+
} = query;
|
|
41
|
+
if (!configuration) return rest;
|
|
42
|
+
return {
|
|
43
|
+
...rest,
|
|
44
|
+
[PRODUCT_QUICK_VIEW_PARAM]: configuration.productNumber,
|
|
45
|
+
...(configuration.without.length && {
|
|
46
|
+
[WITHOUT_INGREDIENTS_PARAM]: configuration.without.join(","),
|
|
47
|
+
}),
|
|
48
|
+
...(configuration.extras.length && {
|
|
49
|
+
[EXTRAS_PARAM]: configuration.extras.join(","),
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
type SeoUrlLike = { seoPathInfo?: string; isCanonical?: boolean };
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The URL of a product (#289): there are no product pages, a product is the
|
|
58
|
+
* quick view over its category, `<category>?produkt=<productNumber>`.
|
|
59
|
+
*
|
|
60
|
+
* The product SEO URL from the backend wins when it is such a deep link (the
|
|
61
|
+
* ShopBite plugin sets the template, shopware-plugin#28), so shop owners can
|
|
62
|
+
* change it in the admin. Otherwise the link is built from the category path
|
|
63
|
+
* the product is listed in. Returns a path, or undefined without either.
|
|
64
|
+
*/
|
|
65
|
+
export function productDeepLink(
|
|
66
|
+
product: { productNumber?: string; seoUrls?: SeoUrlLike[] | null },
|
|
67
|
+
categoryPath?: string,
|
|
68
|
+
): string | undefined {
|
|
69
|
+
const seoUrls = product.seoUrls ?? [];
|
|
70
|
+
const seoPath = (seoUrls.find((url) => url.isCanonical) ?? seoUrls[0])
|
|
71
|
+
?.seoPathInfo;
|
|
72
|
+
if (seoPath && isDeepLink(seoPath)) return withLeadingSlash(seoPath);
|
|
73
|
+
|
|
74
|
+
if (!categoryPath || !product.productNumber) return undefined;
|
|
75
|
+
return withQuery(withLeadingSlash(categoryPath), {
|
|
76
|
+
[PRODUCT_QUICK_VIEW_PARAM]: product.productNumber,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A path with the quick view parameter, e.g. `Speisekarte/Pizza/?produkt=21`. */
|
|
81
|
+
function isDeepLink(path: string): boolean {
|
|
82
|
+
const query = path.split("?")[1];
|
|
83
|
+
return (
|
|
84
|
+
query !== undefined &&
|
|
85
|
+
new URLSearchParams(query).get(PRODUCT_QUICK_VIEW_PARAM) !== null
|
|
86
|
+
);
|
|
87
|
+
}
|