@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
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
|
|
@@ -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>
|
|
@@ -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
|
|
47
|
-
|
|
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
|
|
59
|
-
@keydown.space
|
|
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
|
-
|
|
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
|
|
14
|
-
props.sortedProperties
|
|
15
|
-
|
|
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:
|
|
19
|
+
show: diets.includes("vegetarian"),
|
|
26
20
|
},
|
|
27
|
-
{ label: "Vegan", icon: "i-lucide-vegan", show:
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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>
|
|
@@ -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
|
-
#{{
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,
|