@shopbite-de/storefront 1.29.0 → 1.30.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 +4 -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/useShareLink.ts +47 -0
- package/app/composables/useTopSellers.ts +4 -1
- 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/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/nuxt.config.ts +20 -0
- package/package.json +1 -1
- 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/useShareLink.test.ts +76 -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
|
@@ -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
|
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
export function useShareLink() {
|
|
8
|
+
const toast = useToast();
|
|
9
|
+
const canShare = ref(false);
|
|
10
|
+
|
|
11
|
+
onMounted(() => {
|
|
12
|
+
canShare.value = typeof navigator.share === "function";
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
async function share({ title }: { title?: string } = {}) {
|
|
16
|
+
const url = window.location.href;
|
|
17
|
+
|
|
18
|
+
if (canShare.value) {
|
|
19
|
+
try {
|
|
20
|
+
await navigator.share({ title, url });
|
|
21
|
+
return;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
// Closing the share sheet is no error.
|
|
24
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
await navigator.clipboard.writeText(url);
|
|
32
|
+
toast.add({
|
|
33
|
+
title: "Link kopiert",
|
|
34
|
+
icon: "i-lucide-check",
|
|
35
|
+
color: "success",
|
|
36
|
+
});
|
|
37
|
+
} catch {
|
|
38
|
+
toast.add({
|
|
39
|
+
title: "Link konnte nicht kopiert werden",
|
|
40
|
+
description: url,
|
|
41
|
+
color: "error",
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { share, canShare };
|
|
47
|
+
}
|
|
@@ -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"],
|
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
|
+
}
|
package/app/utils/schema.ts
CHANGED
|
@@ -33,6 +33,12 @@ export type SiteInfo = {
|
|
|
33
33
|
cuisine?: string;
|
|
34
34
|
priceRange?: string;
|
|
35
35
|
googleBusinessProfileUrl?: string;
|
|
36
|
+
/** Places the shop delivers to, e.g. "63179 Obertshausen" (#401). */
|
|
37
|
+
deliveryAreas?: string[];
|
|
38
|
+
/** Nuxt parses numeric env values into numbers. */
|
|
39
|
+
geo?: { latitude?: number | string; longitude?: number | string };
|
|
40
|
+
/** `true`/`false` or a text such as "Nur telefonisch". */
|
|
41
|
+
acceptsReservations?: boolean | string;
|
|
36
42
|
address?: {
|
|
37
43
|
street?: string;
|
|
38
44
|
postalCode?: string;
|
|
@@ -49,11 +55,26 @@ export type MenuSectionInfo = {
|
|
|
49
55
|
|
|
50
56
|
export type MenuItemInfo = {
|
|
51
57
|
name: string;
|
|
58
|
+
/** The quick view deep link of the product (#289). */
|
|
59
|
+
url?: string;
|
|
52
60
|
description?: string;
|
|
61
|
+
/** Main ingredients, the description when the product has none (#400). */
|
|
62
|
+
ingredients?: string[];
|
|
63
|
+
diets?: ("vegetarian" | "vegan")[];
|
|
53
64
|
image?: string;
|
|
54
65
|
price?: number;
|
|
55
66
|
};
|
|
56
67
|
|
|
68
|
+
// Vegan dishes are vegetarian too, so they carry both diets.
|
|
69
|
+
const DIET_URLS = {
|
|
70
|
+
vegetarian: ["https://schema.org/VegetarianDiet"],
|
|
71
|
+
vegan: ["https://schema.org/VegetarianDiet", "https://schema.org/VeganDiet"],
|
|
72
|
+
} as const;
|
|
73
|
+
|
|
74
|
+
function buildSuitableForDiet(diets: MenuItemInfo["diets"]) {
|
|
75
|
+
return [...new Set((diets ?? []).flatMap((diet) => DIET_URLS[diet]))];
|
|
76
|
+
}
|
|
77
|
+
|
|
57
78
|
const formatTime = (time: string) => time.slice(0, 5);
|
|
58
79
|
|
|
59
80
|
/**
|
|
@@ -115,6 +136,39 @@ function buildAddress(address: SiteInfo["address"]) {
|
|
|
115
136
|
});
|
|
116
137
|
}
|
|
117
138
|
|
|
139
|
+
function buildGeo(geo: SiteInfo["geo"]) {
|
|
140
|
+
const latitude = Number(geo?.latitude || NaN);
|
|
141
|
+
const longitude = Number(geo?.longitude || NaN);
|
|
142
|
+
if (Number.isNaN(latitude) || Number.isNaN(longitude)) return undefined;
|
|
143
|
+
return { "@type": "GeoCoordinates", latitude, longitude };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Online ordering as an `OrderAction` on the shop (#401): pickup when the
|
|
148
|
+
* shop has an address, own delivery when delivery areas are configured.
|
|
149
|
+
*/
|
|
150
|
+
function buildOrderAction(orderUrl: string | undefined, site: SiteInfo) {
|
|
151
|
+
if (!orderUrl) return undefined;
|
|
152
|
+
const deliveryMethod = [
|
|
153
|
+
...(site.address?.street ? ["https://schema.org/OnSitePickup"] : []),
|
|
154
|
+
...(site.deliveryAreas?.length
|
|
155
|
+
? ["http://purl.org/goodrelations/v1#DeliveryModeOwnFleet"]
|
|
156
|
+
: []),
|
|
157
|
+
];
|
|
158
|
+
return compact({
|
|
159
|
+
"@type": "OrderAction",
|
|
160
|
+
target: {
|
|
161
|
+
"@type": "EntryPoint",
|
|
162
|
+
urlTemplate: orderUrl,
|
|
163
|
+
actionPlatform: [
|
|
164
|
+
"https://schema.org/DesktopWebPlatform",
|
|
165
|
+
"https://schema.org/MobileWebPlatform",
|
|
166
|
+
],
|
|
167
|
+
},
|
|
168
|
+
deliveryMethod,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
118
172
|
/**
|
|
119
173
|
* The shop as a `Restaurant` (a `LocalBusiness`) with its menu sections.
|
|
120
174
|
* Empty values are left out, so a shop without address or phone still gets a
|
|
@@ -126,6 +180,10 @@ export function buildRestaurantSchema(input: {
|
|
|
126
180
|
holidays?: HolidayLike[];
|
|
127
181
|
menuUrl?: string;
|
|
128
182
|
menuSections?: MenuSectionInfo[];
|
|
183
|
+
/** Set only when online ordering is enabled. */
|
|
184
|
+
orderUrl?: string;
|
|
185
|
+
paymentMethods?: string[];
|
|
186
|
+
currency?: string;
|
|
129
187
|
}) {
|
|
130
188
|
const { site } = input;
|
|
131
189
|
const openingHours = buildOpeningHoursSpecification(
|
|
@@ -148,6 +206,12 @@ export function buildRestaurantSchema(input: {
|
|
|
148
206
|
servesCuisine: site.cuisine,
|
|
149
207
|
priceRange: site.priceRange,
|
|
150
208
|
address: buildAddress(site.address),
|
|
209
|
+
geo: buildGeo(site.geo),
|
|
210
|
+
areaServed: site.deliveryAreas,
|
|
211
|
+
acceptsReservations: site.acceptsReservations,
|
|
212
|
+
paymentAccepted: input.paymentMethods?.join(", "),
|
|
213
|
+
currenciesAccepted: input.currency,
|
|
214
|
+
potentialAction: buildOrderAction(input.orderUrl, site),
|
|
151
215
|
sameAs: site.googleBusinessProfileUrl
|
|
152
216
|
? [site.googleBusinessProfileUrl]
|
|
153
217
|
: undefined,
|
|
@@ -204,8 +268,10 @@ export function buildMenuSectionSchema(input: {
|
|
|
204
268
|
compact({
|
|
205
269
|
"@type": "MenuItem",
|
|
206
270
|
name: item.name,
|
|
207
|
-
|
|
271
|
+
url: item.url,
|
|
272
|
+
description: item.description || item.ingredients?.join(", "),
|
|
208
273
|
image: item.image,
|
|
274
|
+
suitableForDiet: buildSuitableForDiet(item.diets),
|
|
209
275
|
offers:
|
|
210
276
|
item.price !== undefined
|
|
211
277
|
? {
|
|
@@ -222,6 +288,21 @@ export function buildMenuSectionSchema(input: {
|
|
|
222
288
|
});
|
|
223
289
|
}
|
|
224
290
|
|
|
291
|
+
/** Questions and answers as a `FAQPage` (#404). */
|
|
292
|
+
export function buildFaqPageSchema(
|
|
293
|
+
items: { question: string; answer: string }[],
|
|
294
|
+
) {
|
|
295
|
+
return {
|
|
296
|
+
"@context": "https://schema.org",
|
|
297
|
+
"@type": "FAQPage",
|
|
298
|
+
mainEntity: items.map((item) => ({
|
|
299
|
+
"@type": "Question",
|
|
300
|
+
name: item.question,
|
|
301
|
+
acceptedAnswer: { "@type": "Answer", text: item.answer },
|
|
302
|
+
})),
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
225
306
|
/** Drops `undefined`, empty strings and empty arrays. */
|
|
226
307
|
function compact<T extends Record<string, unknown>>(object: T): T {
|
|
227
308
|
return Object.fromEntries(
|
package/app/utils/seo.ts
CHANGED
|
@@ -54,3 +54,16 @@ export function buildHomeDescription({
|
|
|
54
54
|
}
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A comma-separated env value as a list, e.g. the delivery areas (#401).
|
|
60
|
+
* Nuxt parses a JSON array value already.
|
|
61
|
+
*/
|
|
62
|
+
export function splitList(value: unknown): string[] {
|
|
63
|
+
if (Array.isArray(value)) return value.map(String);
|
|
64
|
+
if (typeof value !== "string") return [];
|
|
65
|
+
return value
|
|
66
|
+
.split(",")
|
|
67
|
+
.map((entry) => entry.trim())
|
|
68
|
+
.filter(Boolean);
|
|
69
|
+
}
|
package/content/index.yml
CHANGED
|
@@ -114,6 +114,24 @@ mittagstisch:
|
|
|
114
114
|
color: neutral
|
|
115
115
|
variant: subtle
|
|
116
116
|
trailingIcon: i-lucide-phone
|
|
117
|
+
faq:
|
|
118
|
+
headline: SHOPBITE
|
|
119
|
+
title: Häufige Fragen
|
|
120
|
+
items:
|
|
121
|
+
- question: Wohin liefern Sie?
|
|
122
|
+
answer: Wir liefern nach 63179 Obertshausen (Obertshausen und Hausen) und nach 63165 Mühlheim-Lämmerspiel.
|
|
123
|
+
- question: Was kostet die Lieferung?
|
|
124
|
+
answer: Ab 15 € Bestellwert liefern wir kostenlos. Darunter berechnen wir eine Liefergebühr von 2 €.
|
|
125
|
+
- question: Wie lange dauert die Lieferung?
|
|
126
|
+
answer: Etwa 30 Minuten. Bei der Bestellung können Sie auch eine spätere Lieferzeit wählen.
|
|
127
|
+
- question: Kann ich meine Bestellung abholen?
|
|
128
|
+
answer: Ja, Sie können Ihre Bestellung auch bei uns in der Kantstraße 6 in Obertshausen abholen.
|
|
129
|
+
- question: Wie kann ich bezahlen?
|
|
130
|
+
answer: Bei Lieferung bar, bei Abholung bar oder mit EC-Karte.
|
|
131
|
+
- question: Gibt es vegetarische und vegane Gerichte?
|
|
132
|
+
answer: Ja, vegetarische und vegane Gerichte sind auf der Speisekarte gekennzeichnet.
|
|
133
|
+
- question: Kann ich einen Tisch reservieren?
|
|
134
|
+
answer: Tischreservierungen nehmen wir nur telefonisch entgegen.
|
|
117
135
|
cta:
|
|
118
136
|
title: Jetzt bestellen!
|
|
119
137
|
description: Genieße die italienische Küche, frisch zubereitet und direkt zu dir geliefert oder vor Ort genießen.
|