@shopbite-de/storefront 1.28.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.
Files changed (59) hide show
  1. package/.env.example +9 -0
  2. package/CLAUDE.md +4 -1
  3. package/README.md +14 -14
  4. package/app/components/Category/Listing.vue +1 -0
  5. package/app/components/Home/Faq.vue +58 -0
  6. package/app/components/Home/Highlights.vue +69 -0
  7. package/app/components/Home/MenuCategories.vue +148 -0
  8. package/app/components/Product/Card.vue +46 -10
  9. package/app/components/Product/CardDietBadges.vue +7 -13
  10. package/app/components/Product/CrossSelling.vue +18 -2
  11. package/app/components/Product/DeselectIngredient.vue +10 -3
  12. package/app/components/Product/Detail.vue +33 -2
  13. package/app/components/Product/QuickView.vue +20 -1
  14. package/app/composables/useMenuSectionSchema.ts +21 -8
  15. package/app/composables/useProductCrossSelling.ts +1 -0
  16. package/app/composables/useProductQuickView.ts +151 -9
  17. package/app/composables/useRestaurantSchema.ts +40 -3
  18. package/app/composables/useShareLink.ts +47 -0
  19. package/app/composables/useTopSellers.ts +4 -1
  20. package/app/pages/index.vue +19 -11
  21. package/app/types/Association.d.ts +2 -0
  22. package/app/utils/product.ts +28 -0
  23. package/app/utils/productUrl.ts +87 -0
  24. package/app/utils/schema.ts +82 -1
  25. package/app/utils/seo.ts +13 -0
  26. package/content/index.yml +25 -4
  27. package/content.config.ts +28 -17
  28. package/docs/notes/2026-09-23-issue-388-home-sections.md +45 -0
  29. package/docs/notes/2026-09-25-dependency-update.md +55 -0
  30. package/docs/notes/2026-10-05-issue-289-product-deep-links.md +28 -0
  31. package/docs/notes/2026-10-05-issue-400-menu-item-ingredients-diet.md +18 -0
  32. package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +21 -0
  33. package/docs/notes/2026-10-05-issue-402-llms-txt.md +17 -0
  34. package/docs/notes/2026-10-05-issue-403-ai-crawlers.md +15 -0
  35. package/docs/notes/2026-10-05-issue-404-faq.md +21 -0
  36. package/docs/notes/2026-10-05-issue-411-quick-view-share.md +22 -0
  37. package/nuxt.config.ts +20 -1
  38. package/package.json +9 -10
  39. package/pnpm-workspace.yaml +0 -1
  40. package/server/api/listing/[categoryId].get.ts +3 -0
  41. package/server/api/product/[productId]/cross-selling.get.ts +2 -1
  42. package/server/plugins/ai-crawlers.ts +27 -0
  43. package/server/routes/llms.txt.ts +213 -0
  44. package/server/utils/aiCrawlers.ts +79 -0
  45. package/server/utils/llmsTxt.ts +207 -0
  46. package/test/nuxt/HomeFaq.test.ts +34 -0
  47. package/test/nuxt/HomeMenuCategories.test.ts +94 -0
  48. package/test/nuxt/ProductCrossSelling.test.ts +20 -0
  49. package/test/nuxt/ProductDeselectIngredient.test.ts +34 -0
  50. package/test/nuxt/useShareLink.test.ts +76 -0
  51. package/test/unit/aiCrawlers.spec.ts +48 -0
  52. package/test/unit/llmsTxt.spec.ts +149 -0
  53. package/test/unit/product.spec.ts +20 -0
  54. package/test/unit/productUrl.spec.ts +90 -0
  55. package/test/unit/schema.spec.ts +123 -0
  56. package/test/unit/seo.spec.ts +13 -0
  57. package/app/components/Food/Marquee.vue +0 -35
  58. package/app/components/Food/MarqueeItem.vue +0 -77
  59. package/app/components/Topseller.vue +0 -53
@@ -8,6 +8,9 @@ const props = defineProps<{
8
8
 
9
9
  const open = defineModel<boolean>("open", { required: true });
10
10
 
11
+ const { initial, update: updateConfiguration } = useQuickViewConfiguration();
12
+ const { share, canShare } = useShareLink();
13
+
11
14
  // Bottom sheet on phones, side panel from the lg breakpoint (64rem).
12
15
  const isDesktop = useMediaQuery("(min-width: 64rem)");
13
16
  const direction = computed(() => (isDesktop.value ? "right" : "bottom"));
@@ -18,6 +21,8 @@ const sortedProperties = computed(
18
21
  );
19
22
  const label = ref(props.product?.translated.name ?? props.product?.name ?? "");
20
23
  const description = ref(props.product?.description);
24
+ // Follows the selected variant, like the URL (#411).
25
+ const productNumber = ref(props.product?.productNumber);
21
26
 
22
27
  watch(
23
28
  () => props.product,
@@ -25,12 +30,14 @@ watch(
25
30
  if (!product) return;
26
31
  label.value = product.translated.name ?? product.name;
27
32
  description.value = product.description;
33
+ productNumber.value = product.productNumber;
28
34
  },
29
35
  );
30
36
 
31
37
  function onVariantSelected(variant: Schemas["Product"]) {
32
38
  label.value = variant.translated.name ?? variant.name;
33
39
  description.value = variant.translated.description ?? variant.description;
40
+ productNumber.value = variant.productNumber;
34
41
  }
35
42
  </script>
36
43
 
@@ -52,11 +59,20 @@ function onVariantSelected(variant: Schemas["Product"]) {
52
59
  <template #title>
53
60
  <span class="flex flex-col gap-0.5">
54
61
  <span class="text-xs font-semibold text-primary">
55
- #{{ product?.productNumber }}
62
+ #{{ productNumber }}
56
63
  </span>
57
64
  <span class="text-xl font-bold text-highlighted">{{ label }}</span>
58
65
  </span>
59
66
  </template>
67
+ <template #actions>
68
+ <UButton
69
+ :icon="canShare ? 'i-lucide-share-2' : 'i-lucide-link'"
70
+ color="neutral"
71
+ variant="ghost"
72
+ :aria-label="canShare ? 'Teilen' : 'Link kopieren'"
73
+ @click="share({ title: label })"
74
+ />
75
+ </template>
60
76
  <template v-if="description" #description>
61
77
  {{ description }}
62
78
  </template>
@@ -70,8 +86,11 @@ function onVariantSelected(variant: Schemas["Product"]) {
70
86
  v-if="product"
71
87
  :key="product.id"
72
88
  :product-id="product.id"
89
+ :initial-without="initial.without"
90
+ :initial-extras="initial.extras"
73
91
  @product-added="open = false"
74
92
  @variant-selected="onVariantSelected"
93
+ @configuration-changed="updateConfiguration"
75
94
  />
76
95
  </template>
77
96
  </UDrawer>
@@ -1,12 +1,15 @@
1
1
  import type { Ref } from "vue";
2
2
  import type { Schemas } from "#shopware";
3
+ import { getDiets, getMainIngredients } from "../utils/product";
4
+ import { productDeepLink } from "../utils/productUrl";
3
5
  import { buildMenuSectionSchema } from "../utils/schema";
4
6
  import { toAbsoluteUrl } from "../utils/seo";
5
7
 
6
8
  /**
7
9
  * `MenuSection` JSON-LD for a category page (#272): the category with its
8
10
  * products as `MenuItem`s incl. prices, from the listing that is loaded for
9
- * the page anyway.
11
+ * the page anyway. Ingredients and diets come from the product properties
12
+ * (#400).
10
13
  */
11
14
  export function useMenuSectionSchema(
12
15
  category: Ref<Schemas["Category"] | undefined>,
@@ -29,13 +32,23 @@ export function useMenuSectionSchema(
29
32
  image: current.media?.url,
30
33
  currency: currencyCode.value,
31
34
  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
- })),
35
+ items: products.value.map((product) => {
36
+ const properties = product.sortedProperties as
37
+ Schemas["PropertyGroup"][] | undefined;
38
+ const deepLink = productDeepLink(product, current.seoUrl);
39
+ return {
40
+ name: product.translated?.name ?? product.name,
41
+ url: deepLink ? toAbsoluteUrl(siteConfig.url, deepLink) : undefined,
42
+ description:
43
+ product.translated?.description ?? product.description ?? undefined,
44
+ ingredients: getMainIngredients(properties).map(
45
+ (option) => option.translated?.name ?? option.name,
46
+ ),
47
+ diets: getDiets(properties),
48
+ image: product.cover?.media?.url,
49
+ price: product.calculatedPrice?.unitPrice,
50
+ };
51
+ }),
39
52
  });
40
53
  });
41
54
 
@@ -13,6 +13,7 @@ function mapAssociationToItems(
13
13
  (product: Schemas["Product"]) => ({
14
14
  label: product.name,
15
15
  value: product.id,
16
+ productNumber: product.productNumber,
16
17
  price: getFormattedPrice(product.calculatedPrice.unitPrice),
17
18
  unitPrice: product.calculatedPrice.unitPrice,
18
19
  icon: DEFAULT_ICON,
@@ -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
- /** Query parameter that holds the product number of the open quick view. */
5
- export const PRODUCT_QUICK_VIEW_PARAM = "produkt";
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 product = computed(() =>
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
- ...route.query,
53
- [PRODUCT_QUICK_VIEW_PARAM]: candidate.productNumber,
54
- } satisfies LocationQueryRaw,
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
- const { [PRODUCT_QUICK_VIEW_PARAM]: _omitted, ...query } = route.query;
61
- router.replace({ query });
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: toAbsoluteUrl(siteConfig.url, "/speisekarte"),
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"],
@@ -44,7 +44,17 @@ useRestaurantSchema();
44
44
  :usps="page.hero.usps"
45
45
  />
46
46
 
47
- <Topseller />
47
+ <HomeMenuCategories
48
+ :title="page.menu?.title"
49
+ :description="page.menu?.description"
50
+ :headline="page.menu?.headline"
51
+ />
52
+
53
+ <HomeHighlights
54
+ :title="page.highlights?.title"
55
+ :description="page.highlights?.description"
56
+ :headline="page.highlights?.headline"
57
+ />
48
58
 
49
59
  <USeparator :ui="{ border: 'border-primary/30' }" />
50
60
 
@@ -55,16 +65,6 @@ useRestaurantSchema();
55
65
  :features="page.features.features"
56
66
  />
57
67
 
58
- <USeparator :ui="{ border: 'border-primary/30' }" />
59
-
60
- <LazyFoodMarquee
61
- v-if="page.marquee.items?.length > 0"
62
- :title="page.marquee.title"
63
- :description="page.marquee.description"
64
- :headline="page.marquee.headline"
65
- :items="page.marquee.items"
66
- />
67
-
68
68
  <UPageSection
69
69
  v-if="page.mittagstisch"
70
70
  :reverse="page.mittagstisch.reverse"
@@ -85,12 +85,20 @@ useRestaurantSchema();
85
85
  </UPageSection>
86
86
 
87
87
  <ImageGallery
88
+ v-if="page.gallery?.images?.length"
88
89
  :title="page.gallery.title"
89
90
  :description="page.gallery.description"
90
91
  :headline="page.gallery.headline"
91
92
  :images="page.gallery.images"
92
93
  :links="page.gallery.links"
93
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
+ />
94
102
  <Cta
95
103
  :title="page.cta.title"
96
104
  :description="page.cta.description"
@@ -1,6 +1,8 @@
1
1
  export type AssociationItemProduct = {
2
2
  label: string;
3
3
  value: string;
4
+ /** Identifies the extra in the quick view URL (#411). */
5
+ productNumber?: string;
4
6
  price: string;
5
7
  unitPrice?: number;
6
8
  icon?: string;
@@ -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
+ }