@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
package/.env.example CHANGED
@@ -39,6 +39,15 @@ NUXT_PUBLIC_SITE_TELEPHONE=
39
39
  NUXT_PUBLIC_SITE_GOOGLE_BUSINESS_PROFILE_URL=
40
40
  # Restaurant schema (schema.org), e.g. "€€"
41
41
  NUXT_PUBLIC_SITE_PRICE_RANGE=
42
+ # Comma-separated, e.g. "63179 Obertshausen, 63165 Lämmerspiel"
43
+ NUXT_PUBLIC_SITE_DELIVERY_AREAS=
44
+ NUXT_PUBLIC_SITE_GEO_LATITUDE=
45
+ NUXT_PUBLIC_SITE_GEO_LONGITUDE=
46
+ # true, false or a text such as "Nur telefonisch"
47
+ NUXT_PUBLIC_SITE_ACCEPTS_RESERVATIONS=
48
+ # AI crawlers in robots.txt: search/assistants and model training (#403)
49
+ NUXT_AI_CRAWLERS_SEARCH=true
50
+ NUXT_AI_CRAWLERS_TRAINING=true
42
51
 
43
52
  NUXT_STORE_NAME="ShopBite"
44
53
  STORE_DESCRIPTION="Reduziere deine Kosten und steigere deinen Umsatz"
package/CLAUDE.md CHANGED
@@ -99,7 +99,7 @@ The storefront reads plain Shopware entities with fixed names; seed data must ma
99
99
 
100
100
  - **Navigation:** menu sections are the children of the sales channel navigation root (`readNavigation main-navigation`), optionally scoped by `runtimeConfig.public.shopBite.menuCategoryId`. Category icon comes from the custom field `shopbite_category_icon` (icones.js.org name such as `i-lucide-pizza`), set by the ShopBite plugin.
101
101
  - **Property groups:** `Hauptzutaten` (ingredients on the card, deselectable on the detail page, removed ones are appended to the cart label with "-"), `Vegetarisch` and `Vegan` with the option `Ja` (diet badges), `Küche` (kitchen badge). Filterable groups appear as listing filters.
102
- - **Extras:** product cross-sellings of type `productList`; the cross-selling name is the label ("Extras", "Beilagen"), the assigned products need a price and sales-channel visibility but no category. In the quick view each cross-selling is a collapsible checkbox list that shows 6 entries of a long list and a search field above 15 entries (`Product/CrossSelling.vue`). Selected extras are sent as children of a `container` line item (`useAddToCart.ts`, handled by the ShopBite plugin). The product card has no buttons: the card opens the quick view drawer (`Product/QuickView.vue`), whose state is the `produkt` query parameter (product number) via `useProductQuickView` (#325).
102
+ - **Extras:** product cross-sellings of type `productList`; the cross-selling name is the label ("Extras", "Beilagen"), the assigned products need a price and sales-channel visibility but no category. In the quick view each cross-selling is a collapsible checkbox list that shows 6 entries of a long list and a search field above 15 entries (`Product/CrossSelling.vue`). Selected extras are sent as children of a `container` line item (`useAddToCart.ts`, handled by the ShopBite plugin). The product card has no buttons: the card opens the quick view drawer (`Product/QuickView.vue`), whose state is the `produkt` query parameter (product number) via `useProductQuickView` (#325). That deep link is the product URL (#289, no product pages): `productDeepLink()` (`app/utils/productUrl.ts`) takes the product SEO URL when it carries `?produkt=` (the ShopBite plugin sets the template, shopware-plugin#28; the number must be `|url_encode|raw` in the template, the SEO escaper slugifies `ß`) and otherwise builds it from the category SEO URL. The card name is a stretched link to it (a plain click stays in place); a number not in the list (a variant) is loaded and opens with its options selected. The quick view keeps its configuration in the URL (#411): `ohne` (deselected ingredients by name) and `extras` (extras by product number), written live with `router.replace` by `useQuickViewConfiguration`; a variant switch updates `produkt` without swapping the drawer's product (numbers the drawer switched to itself are pinned). The share button (`useShareLink`) uses the Web Share API, else copies the link.
103
103
  - **Custom fields on products:** `shopbite_receipt_print_type` (`number` prints the menu number on the receipt, `label` prints the name) and `shopbite_delivery_time_factor` (int) and `shopbite_cart_upsell` (bool, suggests the product on the order confirmation step `/bestellung/bestaetigen` via `useCartUpsell`; variant parents are never suggested, a flag on a parent applies to its variants), all from the ShopBite plugin.
104
104
  - **Variants:** standard configurator settings (`Product/Configurator.vue`); `server/api/product/variant.get.ts` resolves a variant by option ids.
105
105
 
@@ -108,6 +108,7 @@ The storefront reads plain Shopware entities with fixed names; seed data must ma
108
108
  `server/api/address/autocomplete.get.ts` — Geoapify proxy (keeps API key server-side).
109
109
  `server/utils/shopware/adminApiClient.ts` — Admin API client for server-side Shopware operations requiring elevated credentials.
110
110
  `server/api/__sitemap__/urls.get.ts` — dynamic `@nuxtjs/sitemap` source (navigation categories from the Store API).
111
+ `server/routes/llms.txt.ts` — `/llms.txt` for AI assistants (#402): shop, hours, ordering and the menu with prices, ingredients and diets as Markdown, built by the pure `server/utils/llmsTxt.ts`; `swr` 1 h. Every Store API source is optional (`Promise.allSettled`), content pages blocked in `robots.txt` are left out.
111
112
  `server/utils/storeApi.ts` — `storeApiPost()` and `MEDIA_INCLUDES` for the routes above. Always send Store API criteria as a POST body (also via `apiClient.invoke("… post …", { body })`): as `_criteria` query parameters Shopware ignores the `includes` projection and returns every field (#312).
112
113
  Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): fatal only in the browser, because a fatal error makes Nitro log a `[request error] [fatal]` block per scanner request (#363).
113
114
  `modules/dev-tooling.ts` registers `@nuxt/eslint`, `@nuxt/hints` and `@nuxt/test-utils/module` only when the storefront itself is the project (not for shops extending the layer, not inside `node_modules`); they are devDependencies, so never add them to `modules` in `nuxt.config.ts` (#378).
@@ -134,6 +135,8 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
134
135
  - `app.vue` sets the title template (`site.titleTemplate`), canonical from the route, `og:url`, fallback `og:image` (`site.ogImage`) and `twitter:card`. Page titles are plain (`"Warenkorb"`), never suffixed with the shop name. Indexable pages use `usePageSeo` (`standalone: true` skips the template, home page); categories use `useCategorySeo`, which overrides the canonical with the SEO URL.
135
136
  - Shopware category SEO URLs end in `/` and 404 without it, but the sitemap module strips trailing slashes from every URL. Sitemap entries that need the slash carry `_trailingSlash: true`; `server/plugins/sitemap-trailing-slash.ts` restores it in the XML. Never normalise trailing slashes of backend SEO URLs.
136
137
  - `@nuxtjs/sitemap` must stay before `@nuxt/content` in `modules`; content collections need the `sitemap` schema field to appear in the sitemap.
138
+ - The home page FAQ (`faq` in `content/index.yml`, `Home/Faq.vue`, #404) uses native `<details>`, not `UAccordion`: Reka unmounts closed panels, and the answers must be in the SSR HTML. The same items feed the `FAQPage` JSON-LD and `/llms.txt`.
139
+ - `server/plugins/ai-crawlers.ts` adds two named robots.txt groups via the `robots:config` hook (#403): AI search/assistant bots and AI training bots (lists with sources in `server/utils/aiCrawlers.ts`), toggled by `runtimeConfig.aiCrawlers.search`/`.training`. A crawler matching a named group ignores `*`, so allowed groups repeat the `robots.disallow` paths.
137
140
  - Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
138
141
 
139
142
  ### Testing setup
package/README.md CHANGED
@@ -32,20 +32,20 @@ talking to the Store API and to the custom routes added by the
32
32
 
33
33
  ## Features
34
34
 
35
- | | |
36
- | ----------------------------- | --------------------------------------------------------------------------- |
37
- | 🕒 **Opening hours** | Multi-interval business hours per weekday, live open/closed state |
38
- | 📅 **Delivery slots** | 5-minute increments, respects prep time, holidays and closing times |
39
- | 🧀 **Extras & toppings** | Configurable products grouped into container line items (UUID v5 reference) |
40
- | 📍 **Address autocomplete** | Geoapify via a server proxy — the API key never reaches the browser |
41
- | 🚚 **Delivery zones** | City/postcode validation before checkout even starts |
42
- | 🎟️ **Vouchers** | Discount codes backed by the ShopBite plugin |
43
- | 📱 **Installable PWA** | Offline-aware service worker, app manifest, mobile bottom navigation |
44
- | ⚡ **SSR + caching** | Server routes with tuned TTLs for products, listings, categories |
45
- | 🔍 **SEO ready** | Sitemap, canonical URLs, share previews, title template, structured data |
46
- | 📊 **Analytics & monitoring** | Matomo via `@nuxt/scripts`, error tracking via Sentry |
47
- | 🎨 **Themeable** | Nuxt UI + Tailwind v4 tokens — brand a shop by overriding CSS variables |
48
- | 🌐 **Multi-channel** | Optional sales channel switching for multi-location businesses |
35
+ | | |
36
+ | --------------------------- | --------------------------------------------------------------------------- |
37
+ | 🕒 **Opening hours** | Multi-interval business hours per weekday, live open/closed state |
38
+ | 📅 **Delivery slots** | 5-minute increments, respects prep time, holidays and closing times |
39
+ | 🧀 **Extras & toppings** | Configurable products grouped into container line items (UUID v5 reference) |
40
+ | 📍 **Address autocomplete** | Geoapify via a server proxy — the API key never reaches the browser |
41
+ | 🚚 **Delivery zones** | City/postcode validation before checkout even starts |
42
+ | 🎟️ **Vouchers** | Discount codes backed by the ShopBite plugin |
43
+ | 📱 **Installable PWA** | Offline-aware service worker, app manifest, mobile bottom navigation |
44
+ | ⚡ **SSR + caching** | Server routes with tuned TTLs for products, listings, categories |
45
+ | 🔍 **SEO ready** | Sitemap, canonical URLs, share previews, title template, structured data |
46
+ | 📊 **Analytics** | Matomo via `@nuxt/scripts` |
47
+ | 🎨 **Themeable** | Nuxt UI + Tailwind v4 tokens — brand a shop by overriding CSS variables |
48
+ | 🌐 **Multi-channel** | Optional sales channel switching for multi-location businesses |
49
49
 
50
50
  ## Quick start
51
51
 
@@ -215,6 +215,7 @@ async function openFilterDrawer() {
215
215
  :product="product"
216
216
  :with-favorite-button="true"
217
217
  :selectable="true"
218
+ :href="productDeepLink(product, category?.seoUrl)"
218
219
  @select="quickView.show"
219
220
  />
220
221
  </div>
@@ -0,0 +1,58 @@
1
+ <script setup lang="ts">
2
+ import { buildFaqPageSchema } from "~/utils/schema";
3
+
4
+ // Frequently asked questions (#404). Native <details> instead of UAccordion:
5
+ // the answers are part of the SSR HTML for search engines and AI crawlers
6
+ // (Reka unmounts closed panels), and the section needs no JavaScript (#314).
7
+ const props = withDefaults(
8
+ defineProps<{
9
+ items: { question: string; answer: string }[];
10
+ title?: string;
11
+ description?: string;
12
+ headline?: string;
13
+ }>(),
14
+ {
15
+ title: "Häufige Fragen",
16
+ description: undefined,
17
+ headline: undefined,
18
+ },
19
+ );
20
+
21
+ useHead(() => ({
22
+ script: [
23
+ {
24
+ key: "jsonld-faq",
25
+ type: "application/ld+json",
26
+ innerHTML: JSON.stringify(buildFaqPageSchema(props.items)),
27
+ },
28
+ ],
29
+ }));
30
+ </script>
31
+
32
+ <template>
33
+ <UPageSection
34
+ id="faq"
35
+ :title="title"
36
+ :description="description"
37
+ :headline="headline"
38
+ :ui="{ container: 'py-12 sm:py-16 lg:py-20' }"
39
+ >
40
+ <div
41
+ class="mx-auto w-full max-w-3xl divide-y divide-default rounded-xl ring ring-default"
42
+ data-testid="faq"
43
+ >
44
+ <details v-for="item in items" :key="item.question" class="group">
45
+ <summary
46
+ class="flex cursor-pointer list-none items-center justify-between gap-4 px-4 py-4 font-semibold text-highlighted focus-visible:outline-2 focus-visible:outline-primary sm:px-6 [&::-webkit-details-marker]:hidden"
47
+ >
48
+ {{ item.question }}
49
+ <UIcon
50
+ name="i-lucide-chevron-down"
51
+ class="size-5 shrink-0 text-muted transition-transform group-open:rotate-180"
52
+ />
53
+ </summary>
54
+ <p class="px-4 pb-4 text-default sm:px-6">{{ item.answer }}</p>
55
+ </details>
56
+ </div>
57
+ </UPageSection>
58
+ </template>
@@ -0,0 +1,69 @@
1
+ <script setup lang="ts">
2
+ import ProductCard from "~/components/Product/Card.vue";
3
+
4
+ // The top sellers (`markAsTopseller`) as a grid of the regular product
5
+ // cards; a tap opens the quick view (#325). Replaces the horizontal
6
+ // scroller and the marquee of the old home page (#388). Renders nothing
7
+ // without top sellers.
8
+ withDefaults(
9
+ defineProps<{
10
+ title?: string;
11
+ description?: string;
12
+ headline?: string;
13
+ }>(),
14
+ {
15
+ title: "Beliebt bei unseren Gästen",
16
+ description: undefined,
17
+ headline: undefined,
18
+ },
19
+ );
20
+
21
+ const { loadTopSellers } = useTopSellers();
22
+
23
+ const { data: topSellers } = await useAsyncData("top-sellers", () =>
24
+ loadTopSellers(),
25
+ );
26
+
27
+ const products = computed(() => topSellers.value ?? []);
28
+ const quickView = useProductQuickView(products);
29
+ </script>
30
+
31
+ <template>
32
+ <UPageSection
33
+ v-if="products.length > 0"
34
+ id="highlights"
35
+ :title="title"
36
+ :description="description"
37
+ :headline="headline"
38
+ :links="[
39
+ {
40
+ label: 'Zur Speisekarte',
41
+ to: '/speisekarte/',
42
+ color: 'primary',
43
+ variant: 'subtle',
44
+ trailingIcon: 'i-lucide-arrow-right',
45
+ },
46
+ ]"
47
+ :ui="{ container: 'py-12 sm:py-16 lg:py-20' }"
48
+ >
49
+ <div
50
+ class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4"
51
+ data-testid="highlights"
52
+ >
53
+ <ProductCard
54
+ v-for="product in products"
55
+ :key="product.id"
56
+ :product="product"
57
+ :with-favorite-button="false"
58
+ :selectable="true"
59
+ :href="productDeepLink(product)"
60
+ @select="quickView.show"
61
+ />
62
+ </div>
63
+ <LazyProductQuickView
64
+ v-if="quickView.mounted.value"
65
+ v-model:open="quickView.open.value"
66
+ :product="quickView.product.value"
67
+ />
68
+ </UPageSection>
69
+ </template>
@@ -0,0 +1,148 @@
1
+ <script setup lang="ts">
2
+ import type { Schemas } from "#shopware";
3
+
4
+ // Tiles of the menu sections directly below the hero (#388): the children
5
+ // of the menu root (`menuCategoryId`, else the navigation root) with the
6
+ // category photo from Shopware (`category.media`) or, without one, the
7
+ // section icon on the brand colour. Every tile links to its listing.
8
+ const props = withDefaults(
9
+ defineProps<{
10
+ title?: string;
11
+ description?: string;
12
+ headline?: string;
13
+ /** Tiles shown before the "all sections" tile. */
14
+ limit?: number;
15
+ }>(),
16
+ {
17
+ title: "Unsere Speisekarte",
18
+ description: undefined,
19
+ headline: undefined,
20
+ limit: 8,
21
+ },
22
+ );
23
+
24
+ const { apiClient } = useShopwareContext();
25
+ const config = useRuntimeConfig();
26
+ const rootId = config.public.shopBite.menuCategoryId || "main-navigation";
27
+
28
+ const { data: categories } = await useAsyncData(
29
+ "home-menu-categories",
30
+ async () => {
31
+ const response = await apiClient.invoke(
32
+ "readNavigation post /navigation/{activeId}/{rootId}",
33
+ {
34
+ body: {
35
+ depth: 1,
36
+ // Sent as a POST body so the projection is honoured (#312).
37
+ includes: {
38
+ category: [
39
+ "id",
40
+ "name",
41
+ "translated",
42
+ "seoUrl",
43
+ "customFields",
44
+ "media",
45
+ ],
46
+ media: ["url", "thumbnails", "metaData"],
47
+ media_thumbnail: ["url", "width"],
48
+ },
49
+ },
50
+ pathParams: { activeId: "main-navigation", rootId },
51
+ },
52
+ );
53
+ return response.data;
54
+ },
55
+ );
56
+
57
+ const tiles = computed(() =>
58
+ (categories.value ?? []).filter((category) => category.seoUrl),
59
+ );
60
+ const visible = computed(() => tiles.value.slice(0, props.limit));
61
+ const hasMore = computed(() => tiles.value.length > props.limit);
62
+
63
+ function name(category: Schemas["Category"]) {
64
+ return category.translated?.name ?? category.name;
65
+ }
66
+
67
+ function icon(category: Schemas["Category"]) {
68
+ return (
69
+ (category.customFields as Record<string, string> | null)
70
+ ?.shopbite_category_icon ?? "i-lucide-utensils"
71
+ );
72
+ }
73
+ </script>
74
+
75
+ <template>
76
+ <UPageSection
77
+ v-if="tiles.length > 0"
78
+ id="speisekarte"
79
+ :title="title"
80
+ :description="description"
81
+ :headline="headline"
82
+ :ui="{ container: 'py-12 sm:py-16 lg:py-20' }"
83
+ >
84
+ <ul
85
+ class="grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4 lg:grid-cols-4"
86
+ data-testid="menu-categories"
87
+ >
88
+ <li v-for="category in visible" :key="category.id">
89
+ <NuxtLink
90
+ :to="category.seoUrl"
91
+ class="group relative isolate flex aspect-[4/3] overflow-hidden rounded-xl bg-neutral-950 ring ring-default transition-shadow hover:shadow-lg hover:ring-primary/40 focus-visible:outline-2 focus-visible:outline-primary"
92
+ >
93
+ <img
94
+ v-if="category.media?.url"
95
+ :src="category.media.url"
96
+ :srcset="mediaSrcSet(category.media)"
97
+ sizes="(min-width: 1024px) 300px, (min-width: 640px) 33vw, 50vw"
98
+ :width="mediaSize(category.media)?.width"
99
+ :height="mediaSize(category.media)?.height"
100
+ alt=""
101
+ loading="lazy"
102
+ decoding="async"
103
+ class="absolute inset-0 -z-20 h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"
104
+ />
105
+ <div
106
+ v-else
107
+ class="absolute inset-0 -z-20 flex items-center justify-center bg-gradient-to-br from-brand-500 to-brand-800 text-white/80"
108
+ aria-hidden="true"
109
+ >
110
+ <UIcon :name="icon(category)" class="size-12 sm:size-16" />
111
+ </div>
112
+ <div
113
+ class="absolute inset-0 -z-10 bg-gradient-to-t from-neutral-950/85 via-neutral-950/30 to-transparent"
114
+ aria-hidden="true"
115
+ />
116
+ <span
117
+ class="mt-auto flex w-full items-center justify-between gap-2 p-3 text-white sm:p-4"
118
+ >
119
+ <span class="flex min-w-0 items-center gap-2">
120
+ <UIcon
121
+ v-if="category.media?.url"
122
+ :name="icon(category)"
123
+ class="size-4 shrink-0 text-white/80"
124
+ />
125
+ <span class="truncate text-base font-bold sm:text-lg">
126
+ {{ name(category) }}
127
+ </span>
128
+ </span>
129
+ <UIcon
130
+ name="i-lucide-arrow-right"
131
+ class="size-4 shrink-0 text-white/80 transition-transform group-hover:translate-x-0.5"
132
+ />
133
+ </span>
134
+ </NuxtLink>
135
+ </li>
136
+ <li v-if="hasMore">
137
+ <NuxtLink
138
+ to="/speisekarte/"
139
+ class="flex aspect-[4/3] flex-col items-center justify-center gap-2 rounded-xl bg-elevated text-primary ring ring-default transition-shadow hover:shadow-lg hover:ring-primary/40 focus-visible:outline-2 focus-visible:outline-primary"
140
+ >
141
+ <UIcon name="i-lucide-layout-grid" class="size-8" />
142
+ <span class="font-bold">Alle Kategorien</span>
143
+ <span class="text-sm text-muted">{{ tiles.length }} Bereiche</span>
144
+ </NuxtLink>
145
+ </li>
146
+ </ul>
147
+ </UPageSection>
148
+ </template>
@@ -7,6 +7,10 @@ const props = defineProps<{
7
7
  // The whole card opens the product quick view (`select`), see
8
8
  // useProductQuickView (#325).
9
9
  selectable: boolean;
10
+ // Deep link of the product (#289). The name becomes a link stretched over
11
+ // the card, so crawlers find the URL; a plain click still opens the quick
12
+ // view in place, a modified click opens the link.
13
+ href?: string;
10
14
  }>();
11
15
 
12
16
  const emit = defineEmits<{
@@ -28,9 +32,28 @@ const { quantity: inCartQuantity } = useProductCartQuantity(
28
32
  const coverMedia = computed(() => product.value.cover?.media);
29
33
  const isAvailable = computed(() => productIsAvailable(product.value));
30
34
 
35
+ const linked = computed(() => props.selectable && !!props.href);
36
+
31
37
  function select() {
32
38
  if (props.selectable) emit("select", product.value);
33
39
  }
40
+
41
+ // Enter/Space on the card itself; a focused link handles Enter natively.
42
+ function onKeydown(event: KeyboardEvent) {
43
+ if (linked.value) return;
44
+ event.preventDefault();
45
+ select();
46
+ }
47
+
48
+ function onLinkClick(event: MouseEvent) {
49
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
50
+ // new tab or window: let the browser follow the link, no quick view
51
+ event.stopPropagation();
52
+ return;
53
+ }
54
+ // the card's click handler opens the quick view
55
+ event.preventDefault();
56
+ }
34
57
  </script>
35
58
 
36
59
  <template>
@@ -43,20 +66,23 @@ function select() {
43
66
  <article
44
67
  class="relative flex h-full flex-col overflow-hidden rounded-xl bg-default shadow-md ring ring-default transition-shadow"
45
68
  :class="{
46
- 'cursor-pointer hover:shadow-lg hover:ring-primary/40 focus-visible:outline-2 focus-visible:outline-primary':
47
- selectable,
69
+ 'cursor-pointer hover:shadow-lg hover:ring-primary/40': selectable,
70
+ 'focus-visible:outline-2 focus-visible:outline-primary':
71
+ selectable && !linked,
72
+ 'has-[a:focus-visible]:outline-2 has-[a:focus-visible]:outline-primary':
73
+ linked,
48
74
  }"
49
- :role="selectable ? 'button' : undefined"
50
- :tabindex="selectable ? 0 : undefined"
51
- :aria-haspopup="selectable ? 'dialog' : undefined"
75
+ :role="selectable && !linked ? 'button' : undefined"
76
+ :tabindex="selectable && !linked ? 0 : undefined"
77
+ :aria-haspopup="selectable && !linked ? 'dialog' : undefined"
52
78
  :aria-label="
53
- selectable
79
+ selectable && !linked
54
80
  ? `${product.translated.name ?? product.name} auswählen`
55
81
  : undefined
56
82
  "
57
83
  @click="select"
58
- @keydown.enter.prevent="select"
59
- @keydown.space.prevent="select"
84
+ @keydown.enter="onKeydown"
85
+ @keydown.space="onKeydown"
60
86
  >
61
87
  <div v-if="coverMedia?.url" class="relative">
62
88
  <img
@@ -81,7 +107,7 @@ function select() {
81
107
  <!-- Stops the click so the wishlist toggle does not open the quick view. -->
82
108
  <div
83
109
  v-if="withFavoriteButton"
84
- class="absolute top-2.5 right-2.5"
110
+ class="absolute top-2.5 right-2.5 z-10"
85
111
  @click.stop
86
112
  @keydown.stop
87
113
  >
@@ -105,7 +131,17 @@ function select() {
105
131
  <ProductCardKitchen :sorted-properties="sortedProperties" />
106
132
  </span>
107
133
  <h3 class="text-lg font-bold text-pretty text-highlighted">
108
- {{ product.translated.name ?? product.name }}
134
+ <a
135
+ v-if="linked"
136
+ :href="href"
137
+ aria-haspopup="dialog"
138
+ class="after:absolute after:inset-0 focus-visible:outline-none"
139
+ @click="onLinkClick"
140
+ >{{ product.translated.name ?? product.name }}</a
141
+ >
142
+ <template v-else>
143
+ {{ product.translated.name ?? product.name }}
144
+ </template>
109
145
  </h3>
110
146
  <p v-if="product.description" class="text-sm text-default">
111
147
  {{ product.description }}
@@ -10,23 +10,17 @@ const props = withDefaults(
10
10
  { variant: "chip" },
11
11
  );
12
12
 
13
- const hasYesOption = (groupName: string) =>
14
- props.sortedProperties?.some(
15
- (group) =>
16
- group.translated.name === groupName &&
17
- group.options?.some((option) => option.translated.name === "Ja"),
18
- ) ?? false;
19
-
20
- const badges = computed(() =>
21
- [
13
+ const badges = computed(() => {
14
+ const diets = getDiets(props.sortedProperties);
15
+ return [
22
16
  {
23
17
  label: "Vegetarisch",
24
18
  icon: "i-lucide-leaf",
25
- show: hasYesOption("Vegetarisch"),
19
+ show: diets.includes("vegetarian"),
26
20
  },
27
- { label: "Vegan", icon: "i-lucide-vegan", show: hasYesOption("Vegan") },
28
- ].filter((badge) => badge.show),
29
- );
21
+ { label: "Vegan", icon: "i-lucide-vegan", show: diets.includes("vegan") },
22
+ ].filter((badge) => badge.show);
23
+ });
30
24
 
31
25
  // Static spans with the UBadge classes, see CardIngredients.vue.
32
26
  const badgeClass = computed(() =>
@@ -8,6 +8,8 @@ import type {
8
8
  // the list renders once and stays put when a variant is switched.
9
9
  const props = defineProps<{
10
10
  associations: AssociationItem[];
11
+ // Product numbers of extras selected via the quick view URL (#411).
12
+ initialExtras?: string[];
11
13
  }>();
12
14
 
13
15
  const emit = defineEmits<{
@@ -21,7 +23,19 @@ const SEARCH_THRESHOLD = 15;
21
23
 
22
24
  const { getFormattedPrice } = useCommercePrice();
23
25
 
24
- const selectedExtras = ref<AssociationItemProduct[]>([]);
26
+ // Each extra once, also if it is in several groups.
27
+ const selectedExtras = ref<AssociationItemProduct[]>([
28
+ ...new Map(
29
+ props.associations
30
+ .flatMap((association) => association.products)
31
+ .filter(
32
+ (extra) =>
33
+ extra.productNumber &&
34
+ props.initialExtras?.includes(extra.productNumber),
35
+ )
36
+ .map((extra) => [extra.value, extra]),
37
+ ).values(),
38
+ ]);
25
39
  // Only the first group starts open, the others show their selection summary.
26
40
  const openGroups = ref<string[]>(
27
41
  props.associations[0] ? [props.associations[0].label] : [],
@@ -78,7 +92,9 @@ function summary(association: AssociationItem) {
78
92
  const baseId = useId();
79
93
  const groupId = (index: number) => `${baseId}-extras-${index}`;
80
94
 
81
- watch(selectedExtras, () => emit("extras-selected", selectedExtras.value));
95
+ watch(selectedExtras, () => emit("extras-selected", selectedExtras.value), {
96
+ immediate: selectedExtras.value.length > 0,
97
+ });
82
98
  </script>
83
99
 
84
100
  <template>
@@ -3,27 +3,34 @@ import type { Schemas } from "#shopware";
3
3
 
4
4
  const props = defineProps<{
5
5
  product: Schemas["Product"];
6
+ // Ingredient names deselected via the quick view URL (#411).
7
+ initialDeselected?: string[];
6
8
  }>();
7
9
 
8
10
  const emit = defineEmits<{
9
11
  "ingredients-deselected": [deselected: string[]];
10
12
  }>();
11
13
 
12
- const deselected = ref<string[]>([]);
13
-
14
14
  const ingredients = computed<string[]>(() =>
15
15
  ((props.product.properties ?? []) as Schemas["PropertyGroupOption"][])
16
16
  .filter((option) => option.group?.name === "Hauptzutaten")
17
17
  .map((option) => option.translated.name),
18
18
  );
19
19
 
20
+ // Names that are no ingredient of the product (renamed, typo) are ignored.
21
+ const deselected = ref<string[]>(
22
+ ingredients.value.filter((name) => props.initialDeselected?.includes(name)),
23
+ );
24
+
20
25
  function toggle(ingredient: string) {
21
26
  deselected.value = deselected.value.includes(ingredient)
22
27
  ? deselected.value.filter((name) => name !== ingredient)
23
28
  : [...deselected.value, ingredient];
24
29
  }
25
30
 
26
- watch(deselected, () => emit("ingredients-deselected", deselected.value));
31
+ watch(deselected, () => emit("ingredients-deselected", deselected.value), {
32
+ immediate: deselected.value.length > 0,
33
+ });
27
34
  </script>
28
35
 
29
36
  <template>
@@ -1,12 +1,20 @@
1
1
  <script setup lang="ts">
2
2
  import type { Schemas } from "#shopware";
3
3
  import type { AssociationItemProduct } from "~/types/Association";
4
+ import type { QuickViewConfiguration } from "~/utils/productUrl";
4
5
 
5
6
  const props = defineProps<{
6
7
  productId: string;
8
+ // Configuration from the quick view URL (#411).
9
+ initialWithout?: string[];
10
+ initialExtras?: string[];
7
11
  }>();
8
12
 
9
- const emit = defineEmits(["product-added", "variant-selected"]);
13
+ const emit = defineEmits<{
14
+ "product-added": [];
15
+ "variant-selected": [variant: Schemas["Product"]];
16
+ "configuration-changed": [configuration: QuickViewConfiguration];
17
+ }>();
10
18
 
11
19
  const {
12
20
  productDetails,
@@ -24,10 +32,30 @@ const {
24
32
  const { getFormattedPrice } = useCommercePrice();
25
33
 
26
34
  const selectedExtras = ref<AssociationItemProduct[]>([]);
35
+ const deselectedIngredients = ref<string[]>([]);
27
36
 
28
37
  function onExtras(extras: AssociationItemProduct[]) {
29
38
  selectedExtras.value = extras;
30
39
  onExtrasSelected(extras);
40
+ emitConfiguration();
41
+ }
42
+
43
+ function onIngredients(deselected: string[]) {
44
+ deselectedIngredients.value = deselected;
45
+ onIngredientsDeselected(deselected);
46
+ emitConfiguration();
47
+ }
48
+
49
+ function emitConfiguration() {
50
+ const productNumber = selectedProduct.value?.productNumber;
51
+ if (!productNumber) return;
52
+ emit("configuration-changed", {
53
+ productNumber,
54
+ without: deselectedIngredients.value,
55
+ extras: selectedExtras.value
56
+ .map((extra) => extra.productNumber)
57
+ .filter((number): number is string => !!number),
58
+ });
31
59
  }
32
60
 
33
61
  // Unit price plus extras, times the quantity: what the button will add.
@@ -47,6 +75,7 @@ const isAvailable = computed(() =>
47
75
  const onVariantSwitched = (variant: Schemas["Product"]) => {
48
76
  setSelectedProduct(variant);
49
77
  emit("variant-selected", variant);
78
+ emitConfiguration();
50
79
  };
51
80
 
52
81
  const onAddToCart = () => emit("product-added");
@@ -85,11 +114,13 @@ const onAddToCart = () => emit("product-added");
85
114
  <ProductDeselectIngredient
86
115
  v-if="selectedProduct"
87
116
  :product="selectedProduct"
88
- @ingredients-deselected="onIngredientsDeselected"
117
+ :initial-deselected="initialWithout"
118
+ @ingredients-deselected="onIngredients"
89
119
  />
90
120
  <ProductCrossSelling
91
121
  v-if="associationItems.length > 0"
92
122
  :associations="associationItems"
123
+ :initial-extras="initialExtras"
93
124
  @extras-selected="onExtras"
94
125
  />
95
126
  </template>