@shopbite-de/storefront 2.2.0 → 2.3.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/CLAUDE.md +11 -6
- package/app/app.vue +9 -6
- package/app/components/Category/Breadcrumb.vue +9 -10
- package/app/components/Category/Listing.vue +0 -1
- package/app/components/Checkout/Summary.vue +27 -2
- package/app/components/Header.vue +2 -2
- package/app/components/Menu/BonCard.vue +0 -13
- package/app/components/Product/FoodLabels.vue +47 -20
- package/app/components/Product/QuickView.vue +1 -1
- package/app/components/Sb/Icon.vue +3 -1
- package/app/composables/useBusinessHours.ts +35 -14
- package/app/composables/useHolidays.ts +31 -11
- package/app/composables/useHomeMenuCategories.ts +6 -34
- package/app/composables/useLiveShopData.ts +17 -0
- package/app/composables/useNavigation.ts +14 -66
- package/app/composables/useNavigationSearch.ts +8 -31
- package/app/composables/useRestaurantSchema.ts +2 -13
- package/app/composables/useSeoUrlRoute.ts +21 -0
- package/app/composables/useShopBiteConfig.ts +50 -6
- package/app/composables/useTopSellers.ts +2 -43
- package/app/error.vue +4 -0
- package/app/utils/product.ts +1 -62
- package/docs/notes/2026-09-10-issue-275-accessibility.md +2 -2
- package/docs/notes/2026-09-12-issue-327-home-hero.md +1 -1
- package/docs/notes/2026-09-13-issue-332-home-info-cards.md +1 -3
- package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +1 -1
- package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +1 -1
- package/docs/notes/2026-09-23-issue-388-home-sections.md +2 -2
- package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +1 -1
- package/modules/theme.ts +1 -1
- package/nuxt.config.ts +13 -0
- package/package.json +5 -5
- package/server/api/_cache/purge.post.ts +6 -3
- package/server/api/breadcrumb/[categoryId].get.ts +31 -0
- package/server/api/navigation/[type].get.ts +97 -0
- package/server/api/payment-methods.get.ts +29 -0
- package/server/api/seo-url/index.get.ts +17 -0
- package/server/api/seo-url/known.get.ts +33 -0
- package/server/api/shopbite/business-hours.get.ts +22 -0
- package/server/api/shopbite/config.get.ts +6 -0
- package/server/api/shopbite/holidays.get.ts +20 -0
- package/server/api/top-sellers.get.ts +59 -0
- package/server/utils/backoff.ts +67 -0
- package/server/utils/cachePurge.ts +45 -12
- package/server/utils/menuRoot.ts +24 -18
- package/server/utils/seoPaths.ts +130 -0
- package/server/utils/seoUrlCache.ts +98 -0
- package/server/utils/shopBiteConfig.ts +30 -0
- package/server/utils/storeApi.ts +22 -0
- package/test/layer/nuxt.config.ts +1 -1
- package/test/nuxt/CheckoutSummary.test.ts +38 -2
- package/test/nuxt/ProductFoodLabels.test.ts +70 -0
- package/test/nuxt/liveShopData.test.ts +114 -0
- package/test/nuxt/useShopBiteConfig.test.ts +22 -0
- package/test/nuxt/useTopSellers.test.ts +10 -27
- package/test/unit/cachePurge.spec.ts +41 -0
- package/test/unit/layoutCacheRoutes.spec.ts +566 -0
- package/test/unit/nitroStubs.ts +99 -0
- package/test/unit/product.spec.ts +1 -23
- package/test/unit/seoPaths.spec.ts +117 -0
- package/app/components/Menu/FoodLabelLegend.vue +0 -28
|
@@ -9,41 +9,16 @@ export interface NavigationMenuItem {
|
|
|
9
9
|
children?: NavigationMenuItem[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Sent as a POST body: as `_criteria` query parameters the projection is
|
|
17
|
-
// ignored and every category arrives with media, translations, cms page
|
|
18
|
-
// and more (#312).
|
|
19
|
-
const criteria = {
|
|
20
|
-
includes: {
|
|
21
|
-
category: [
|
|
22
|
-
"id",
|
|
23
|
-
"name",
|
|
24
|
-
"translated",
|
|
25
|
-
"seoUrl",
|
|
26
|
-
"customFields",
|
|
27
|
-
"children",
|
|
28
|
-
"linkNewTab",
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
};
|
|
12
|
+
/** Loads a navigation from the server cache (server/api/navigation). */
|
|
13
|
+
const fetchNavigation = (type: "main" | "footer" | "menu") =>
|
|
14
|
+
$fetch<Schemas["Category"][]>(`/api/navigation/${type}`);
|
|
32
15
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
activeId: "main-navigation",
|
|
40
|
-
rootId: "main-navigation",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
return response.data;
|
|
46
|
-
});
|
|
16
|
+
export function useNavigation(withChildren: boolean | undefined) {
|
|
17
|
+
// Every page renders these, a 404 too: the server keeps them
|
|
18
|
+
// (server/api/navigation) instead of asking Shopware per request.
|
|
19
|
+
const { data: mainNavigation } = useAsyncData("main-navigation", () =>
|
|
20
|
+
fetchNavigation("main"),
|
|
21
|
+
);
|
|
47
22
|
|
|
48
23
|
const mapCategoryToMenuItem = (
|
|
49
24
|
category: Schemas["Category"],
|
|
@@ -65,22 +40,8 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
65
40
|
return mainNavigation.value?.map(mapCategoryToMenuItem);
|
|
66
41
|
});
|
|
67
42
|
|
|
68
|
-
const { data: footerNavigation } = useAsyncData(
|
|
69
|
-
"footer
|
|
70
|
-
async () => {
|
|
71
|
-
const response = await apiClient.invoke(
|
|
72
|
-
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
73
|
-
{
|
|
74
|
-
body: criteria,
|
|
75
|
-
pathParams: {
|
|
76
|
-
activeId: "footer-navigation",
|
|
77
|
-
rootId: "footer-navigation",
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
return response.data;
|
|
83
|
-
},
|
|
43
|
+
const { data: footerNavigation } = useAsyncData("footer-navigation", () =>
|
|
44
|
+
fetchNavigation("footer"),
|
|
84
45
|
);
|
|
85
46
|
|
|
86
47
|
const footerMenu = computed<NavigationMenuItem[]>(() => {
|
|
@@ -89,22 +50,9 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
89
50
|
return footerNavigation.value?.map(mapCategoryToMenuItem);
|
|
90
51
|
});
|
|
91
52
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const response = await apiClient.invoke(
|
|
96
|
-
"readNavigation post /navigation/{activeId}/{rootId}",
|
|
97
|
-
{
|
|
98
|
-
body: criteria,
|
|
99
|
-
pathParams: {
|
|
100
|
-
activeId: "main-navigation",
|
|
101
|
-
rootId: await menuRootId(),
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
return response.data;
|
|
107
|
-
},
|
|
53
|
+
// The menu sections below the menu root (#486, resolved on the server).
|
|
54
|
+
const { data: menuCardNavigation } = useAsyncData("menu-category", () =>
|
|
55
|
+
fetchNavigation("menu"),
|
|
108
56
|
);
|
|
109
57
|
|
|
110
58
|
const menuCardMenu = computed<NavigationMenuItem[]>(() => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useSessionContext
|
|
1
|
+
import { useSessionContext } from "#imports";
|
|
2
2
|
import type { Schemas } from "#shopware";
|
|
3
|
-
import { encodeForQuery } from "@shopware/api-client/helpers";
|
|
4
3
|
|
|
5
4
|
export type UseNavigationSearchReturn = {
|
|
6
5
|
/**
|
|
@@ -16,7 +15,6 @@ export type UseNavigationSearchReturn = {
|
|
|
16
15
|
* @category Navigation & Routing
|
|
17
16
|
*/
|
|
18
17
|
export function useNavigationSearch(): UseNavigationSearchReturn {
|
|
19
|
-
const { apiClient } = useShopwareContext();
|
|
20
18
|
const { sessionContext } = useSessionContext();
|
|
21
19
|
|
|
22
20
|
async function resolvePath(path: string): Promise<Schemas["SeoUrl"] | null> {
|
|
@@ -31,35 +29,14 @@ export function useNavigationSearch(): UseNavigationSearchReturn {
|
|
|
31
29
|
} as Schemas["SeoUrl"];
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
// Matches are cached on the server (server/api/seo-url), so a menu
|
|
33
|
+
// section does not ask Shopware for its SEO URL on every request.
|
|
34
|
+
const { seoUrl } = await $fetch<{ seoUrl: Schemas["SeoUrl"] | null }>(
|
|
35
|
+
"/api/seo-url",
|
|
36
|
+
{ query: { path } },
|
|
37
|
+
);
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
const normalizedPath = isTechnicalUrl
|
|
41
|
-
? path.endsWith("/")
|
|
42
|
-
? path.slice(0, -1)
|
|
43
|
-
: path
|
|
44
|
-
: path.substring(1);
|
|
45
|
-
|
|
46
|
-
const criteria = encodeForQuery({
|
|
47
|
-
filter: [
|
|
48
|
-
{
|
|
49
|
-
type: "equals",
|
|
50
|
-
field: isTechnicalUrl ? "pathInfo" : "seoPathInfo",
|
|
51
|
-
value: normalizedPath,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const seoResult = await apiClient.invoke("readSeoUrlGet get /seo-url", {
|
|
57
|
-
query: {
|
|
58
|
-
_criteria: criteria,
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return seoResult.data.elements?.[0] ?? null;
|
|
39
|
+
return seoUrl;
|
|
63
40
|
}
|
|
64
41
|
|
|
65
42
|
return {
|
|
@@ -18,24 +18,13 @@ export function useRestaurantSchema() {
|
|
|
18
18
|
const { menuCardMenu } = useNavigation(true);
|
|
19
19
|
const { isCheckoutEnabled } = useShopBiteConfig();
|
|
20
20
|
const { currencyCode } = useCommercePrice();
|
|
21
|
-
const { apiClient } = useShopwareContext();
|
|
22
21
|
|
|
22
|
+
// Cached on the server (server/api/payment-methods).
|
|
23
23
|
const { data: paymentMethods } = useAsyncData(
|
|
24
24
|
"restaurant-schema-payment-methods",
|
|
25
25
|
async () => {
|
|
26
26
|
try {
|
|
27
|
-
|
|
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
|
-
);
|
|
27
|
+
return await $fetch<string[]>("/api/payment-methods");
|
|
39
28
|
} catch (error) {
|
|
40
29
|
console.error("Failed to load payment methods", error);
|
|
41
30
|
return [];
|
|
@@ -29,6 +29,15 @@ export async function useSeoUrlRoute() {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// A path no category ever had (a scanner probing `/wp-admin/`) is
|
|
33
|
+
// answered from the server's list of SEO paths, not by four lookups.
|
|
34
|
+
if (import.meta.server && !(await mayBeSeoPath(routePath))) {
|
|
35
|
+
throw createError({
|
|
36
|
+
statusCode: 404,
|
|
37
|
+
statusMessage: `No data fetched from API for ${routePath}`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
const { match, redirectPath } = await resolveSeoPath(
|
|
33
42
|
routePath,
|
|
34
43
|
resolveCategoryPath,
|
|
@@ -57,6 +66,18 @@ export async function useSeoUrlRoute() {
|
|
|
57
66
|
);
|
|
58
67
|
}
|
|
59
68
|
|
|
69
|
+
async function mayBeSeoPath(path: string): Promise<boolean> {
|
|
70
|
+
if (path === "/") return true;
|
|
71
|
+
try {
|
|
72
|
+
const { known } = await $fetch<{ known: boolean }>("/api/seo-url/known", {
|
|
73
|
+
query: { path },
|
|
74
|
+
});
|
|
75
|
+
return known;
|
|
76
|
+
} catch {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
60
81
|
async function resolveCategoryPath(
|
|
61
82
|
path: string,
|
|
62
83
|
): Promise<Schemas["SeoUrl"] | null> {
|
|
@@ -1,14 +1,58 @@
|
|
|
1
|
+
import type { Schemas } from "#shopware";
|
|
2
|
+
|
|
3
|
+
export const SHOPBITE_CONFIG_KEY = "shopbite-config";
|
|
4
|
+
|
|
5
|
+
type ApiClient = ReturnType<typeof useShopwareContext>["apiClient"];
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The plugin configuration: from the server's short-lived cache
|
|
9
|
+
* (`/api/shopbite/config`, `cacheTtl.config`) for server-side rendering,
|
|
10
|
+
* from Shopware in the browser. The plugin does not enforce the checkout
|
|
11
|
+
* switch itself, so the browser's value must be fresh: app.vue reloads it
|
|
12
|
+
* after hydration (useLiveShopData), the checkout every 10 s.
|
|
13
|
+
*/
|
|
14
|
+
export async function loadShopBiteConfig(
|
|
15
|
+
apiClient: ApiClient,
|
|
16
|
+
fromServerCache: boolean,
|
|
17
|
+
retryDelays: readonly number[] = OPENING_HOURS_RETRY_DELAYS,
|
|
18
|
+
): Promise<Schemas["ShopBiteConfig"]> {
|
|
19
|
+
if (fromServerCache) {
|
|
20
|
+
return await $fetch<Schemas["ShopBiteConfig"]>("/api/shopbite/config");
|
|
21
|
+
}
|
|
22
|
+
// retried in the browser like the opening hours (#355)
|
|
23
|
+
const { data } = await withRetries(
|
|
24
|
+
() => apiClient.invoke("shopbite.config.get get /shopbite/config"),
|
|
25
|
+
retryDelays,
|
|
26
|
+
);
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
|
|
1
30
|
export function useShopBiteConfig() {
|
|
2
31
|
const { apiClient } = useShopwareContext();
|
|
3
32
|
|
|
4
|
-
const { data, refresh } = useAsyncData(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
33
|
+
const { data, refresh } = useAsyncData(SHOPBITE_CONFIG_KEY, () =>
|
|
34
|
+
loadShopBiteConfig(apiClient, import.meta.server),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Asks Shopware (never the server cache) right before an order: the
|
|
39
|
+
* plugin does not refuse orders itself, so the checkout must not act on
|
|
40
|
+
* a value from the server render. `null` when it cannot be checked.
|
|
41
|
+
*/
|
|
42
|
+
async function checkCheckoutEnabled(
|
|
43
|
+
retryDelays?: readonly number[],
|
|
44
|
+
): Promise<boolean | null> {
|
|
45
|
+
try {
|
|
46
|
+
data.value = await loadShopBiteConfig(apiClient, false, retryDelays);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("[checkout][checkCheckoutEnabled]", error);
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return data.value?.isCheckoutEnabled ?? false;
|
|
52
|
+
}
|
|
10
53
|
|
|
11
54
|
return {
|
|
55
|
+
checkCheckoutEnabled,
|
|
12
56
|
deliveryTime: computed(() => data.value?.deliveryTime ?? 30),
|
|
13
57
|
isCheckoutEnabled: computed(() => data.value?.isCheckoutEnabled ?? false),
|
|
14
58
|
refresh,
|
|
@@ -4,52 +4,11 @@ export type useTopSellersReturn = {
|
|
|
4
4
|
loadTopSellers(): Promise<Schemas["Product"][]>;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
const TOP_SELLERS_LIMIT = 8;
|
|
8
|
-
|
|
9
7
|
export function useTopSellers(): useTopSellersReturn {
|
|
10
|
-
const { apiClient } = useShopwareContext();
|
|
11
8
|
async function loadTopSellers() {
|
|
12
9
|
try {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// @ts-expect-error sw-inheritance is missing from the generated header type
|
|
17
|
-
headers: { "sw-inheritance": "true", "sw-include-seo-urls": "true" },
|
|
18
|
-
body: {
|
|
19
|
-
filter: [{ type: "equals", field: "markAsTopseller", value: true }],
|
|
20
|
-
limit: TOP_SELLERS_LIMIT,
|
|
21
|
-
// What the compact card and the quick view need (#327).
|
|
22
|
-
includes: {
|
|
23
|
-
product: [
|
|
24
|
-
"id",
|
|
25
|
-
"productNumber",
|
|
26
|
-
"name",
|
|
27
|
-
"translated",
|
|
28
|
-
"description",
|
|
29
|
-
"calculatedPrice",
|
|
30
|
-
"available",
|
|
31
|
-
"cover",
|
|
32
|
-
"sortedProperties",
|
|
33
|
-
// Allergens checked (#485); includes filter `translated` as well,
|
|
34
|
-
// so custom fields only come back when listed here.
|
|
35
|
-
"customFields",
|
|
36
|
-
// Card link to the quick view deep link (#289).
|
|
37
|
-
"seoUrls",
|
|
38
|
-
],
|
|
39
|
-
seo_url: ["seoPathInfo", "isCanonical"],
|
|
40
|
-
product_media: ["media"],
|
|
41
|
-
media: ["url", "thumbnails"],
|
|
42
|
-
media_thumbnail: ["width", "url"],
|
|
43
|
-
property_group: ["id", "name", "translated", "options"],
|
|
44
|
-
property_group_option: ["id", "name", "translated", "customFields"],
|
|
45
|
-
},
|
|
46
|
-
associations: {
|
|
47
|
-
cover: { associations: { media: {} } },
|
|
48
|
-
properties: { associations: { group: {} } },
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
return result.data.elements;
|
|
10
|
+
// Cached on the server like the listings (server/api/top-sellers).
|
|
11
|
+
return await $fetch<Schemas["Product"][]>("/api/top-sellers");
|
|
53
12
|
} catch (e) {
|
|
54
13
|
console.error("[useTopSellers][loadTopSellers]", e);
|
|
55
14
|
return [];
|
package/app/error.vue
CHANGED
|
@@ -13,6 +13,10 @@ const pageTitle = computed(() => `${statusCode} | ${site?.name}`);
|
|
|
13
13
|
|
|
14
14
|
console.error(props.error);
|
|
15
15
|
|
|
16
|
+
// error.vue replaces app.vue: load the checkout switch, hours and closing
|
|
17
|
+
// days from Shopware after hydration here as well (useLiveShopData).
|
|
18
|
+
useLiveShopData();
|
|
19
|
+
|
|
16
20
|
const statusCode = props.error.statusCode;
|
|
17
21
|
|
|
18
22
|
useSeoMeta({
|
package/app/utils/product.ts
CHANGED
|
@@ -72,27 +72,6 @@ export function getDiets(
|
|
|
72
72
|
const ALLERGEN_GROUP = "Allergene";
|
|
73
73
|
const ADDITIVE_GROUP = "Zusatzstoffe";
|
|
74
74
|
|
|
75
|
-
/**
|
|
76
|
-
* Names of the allergen codes for the legend. The options name the cereal
|
|
77
|
-
* or nut (LMIV Annex II), the legend names the allergen.
|
|
78
|
-
*/
|
|
79
|
-
export const ALLERGEN_CODE_NAMES: Record<string, string> = {
|
|
80
|
-
A: "Glutenhaltiges Getreide",
|
|
81
|
-
B: "Krebstiere",
|
|
82
|
-
C: "Eier",
|
|
83
|
-
D: "Fisch",
|
|
84
|
-
E: "Erdnüsse",
|
|
85
|
-
F: "Soja",
|
|
86
|
-
G: "Milch",
|
|
87
|
-
H: "Schalenfrüchte",
|
|
88
|
-
L: "Sellerie",
|
|
89
|
-
M: "Senf",
|
|
90
|
-
N: "Sesam",
|
|
91
|
-
O: "Schwefeldioxid und Sulfite",
|
|
92
|
-
P: "Lupinen",
|
|
93
|
-
R: "Weichtiere",
|
|
94
|
-
};
|
|
95
|
-
|
|
96
75
|
export interface FoodLabel {
|
|
97
76
|
code: string;
|
|
98
77
|
name: string;
|
|
@@ -143,18 +122,7 @@ export function allergensChecked(product: Schemas["Product"]): boolean {
|
|
|
143
122
|
return customFieldsOf(product).shopbite_allergens_checked === true;
|
|
144
123
|
}
|
|
145
124
|
|
|
146
|
-
/**
|
|
147
|
-
export function foodLabelCodes(labels: FoodLabels): string[] {
|
|
148
|
-
return [
|
|
149
|
-
...new Set(
|
|
150
|
-
[...labels.allergens, ...labels.additives]
|
|
151
|
-
.map((label) => label.code)
|
|
152
|
-
.filter(Boolean),
|
|
153
|
-
),
|
|
154
|
-
];
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/** Plain text for the product sheet and screen readers. */
|
|
125
|
+
/** Plain text for the info popover of the product sheet (#500). */
|
|
158
126
|
export function foodLabelText(labels: FoodLabels): string {
|
|
159
127
|
const parts: string[] = [];
|
|
160
128
|
if (labels.allergens.length) {
|
|
@@ -169,32 +137,3 @@ export function foodLabelText(labels: FoodLabels): string {
|
|
|
169
137
|
}
|
|
170
138
|
return parts.join(" ");
|
|
171
139
|
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Legend of the codes used in a list of products: allergens by their
|
|
175
|
-
* allergen name, additives by their option name, sorted like a menu.
|
|
176
|
-
*/
|
|
177
|
-
export function foodLabelLegend(products: Schemas["Product"][]): FoodLabel[] {
|
|
178
|
-
const legend = new Map<string, string>();
|
|
179
|
-
for (const product of products) {
|
|
180
|
-
const labels = getFoodLabels(
|
|
181
|
-
product.sortedProperties as Schemas["PropertyGroup"][] | undefined,
|
|
182
|
-
);
|
|
183
|
-
for (const label of labels.allergens) {
|
|
184
|
-
if (label.code)
|
|
185
|
-
legend.set(label.code, ALLERGEN_CODE_NAMES[label.code] ?? label.name);
|
|
186
|
-
}
|
|
187
|
-
for (const label of labels.additives) {
|
|
188
|
-
if (label.code) legend.set(label.code, label.name);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return [...legend]
|
|
192
|
-
.map(([code, name]) => ({ code, name }))
|
|
193
|
-
.sort((a, b) => {
|
|
194
|
-
const numeric = Number(a.code) - Number(b.code);
|
|
195
|
-
if (!Number.isNaN(numeric)) return numeric;
|
|
196
|
-
if (Number.isNaN(Number(a.code)) !== Number.isNaN(Number(b.code)))
|
|
197
|
-
return Number.isNaN(Number(a.code)) ? -1 : 1;
|
|
198
|
-
return a.code.localeCompare(b.code);
|
|
199
|
-
});
|
|
200
|
-
}
|
|
@@ -25,7 +25,7 @@ So the storefront default and both demos fail in light mode as well; nobody had
|
|
|
25
25
|
- Contrast: Nuxt UI convention. `--ui-primary` is `brand-600` in light mode and `brand-400` in dark mode; the storefront's own `brand-600` becomes `#c23d00` (5.30 on white, 4.59 on its tint). `--ui-success` is `green-800` light / `green-400` dark. Rule for demos: `brand-600` ≥ 5:1 on white (covers the tint), `brand-400` ≥ 4.5:1 on `#171717`.
|
|
26
26
|
- Toast proxies: instead of patching `reka-ui` (tried first: a pnpm patch of `dist/Toast/FocusProxy.{js,cjs}` without `aria-hidden` cleared the audit), the **status toasts are gone**. A permanent "closed" toast was a misuse of a transient notification; the status is now a line above the opening hours in the footer (`components/Footer/StoreStatus.vue`, `useStoreStatus`). A chip next to the logo was tried first: on phones only the dot fit, on the desktop the text ran into the navigation, and inside the logo link it broke the link's accessible name. Transient toasts stay on Nuxt UI; their proxies only exist for seconds. Upstream issue for the proxy still worth filing.
|
|
27
27
|
- The status line is client only (`ClientOnly` with a placeholder of the same size): the open/closed state depends on the current time, and the server's clock/time zone is not the shop's. Server-rendered status would need a configured time zone; separate issue if wanted.
|
|
28
|
-
- La Fattoria keeps its own `main.css`; the same `--ui-primary` and `--ui-success` changes went there
|
|
28
|
+
- La Fattoria keeps its own `main.css`; the same `--ui-primary` and `--ui-success` changes went there.
|
|
29
29
|
|
|
30
30
|
## Implementation
|
|
31
31
|
|
|
@@ -34,7 +34,7 @@ So the storefront default and both demos fail in light mode as well; nobody had
|
|
|
34
34
|
- `useStoreStatus`: open → closing time of the current interval; closed → `getNextOpeningTime`. Refreshes the clock every minute. `app.vue` keeps loading business hours and holidays on mount but no longer shows toasts.
|
|
35
35
|
- `Footer/StoreStatus.vue`: "Geöffnet bis 23:00 Uhr" or "Geschlossen, wir öffnen wieder …", no link (the old toast's "Zur Speisekarte" action was dropped on purpose). `role="status"`, placeholder of the same height while unknown.
|
|
36
36
|
- `--ui-text-muted` in light mode is `#6b6b6b` (was `#737373`, 4.38:1 on `--ui-bg-elevated`, the header navigation background). `UHeader` gets `:title="site.name"`: Nuxt UI's default made the logo link read "Nuxt UI".
|
|
37
|
-
- Docs: contrast rule in
|
|
37
|
+
- Docs: contrast rule in https://shopbite.de/docs/storefront/configuration (DE/EN) and the demo-shop checklist in the root `CLAUDE.md`.
|
|
38
38
|
|
|
39
39
|
## Not covered
|
|
40
40
|
|
|
@@ -40,7 +40,7 @@ top sellers as a horizontal scroller.
|
|
|
40
40
|
sellers carry the parent's name and cover (La Fattoria marks both the
|
|
41
41
|
parent "Cordon Bleu" and its three variants; the header type of the
|
|
42
42
|
generated operation lacks `sw-inheritance`, hence the `@ts-expect-error`).
|
|
43
|
-
-
|
|
43
|
+
- Docs (https://shopbite.de/docs/storefront/content, DE/EN)
|
|
44
44
|
describe `hero.title`, the status line, the link order and the top
|
|
45
45
|
sellers.
|
|
46
46
|
|
|
@@ -31,9 +31,7 @@ A (three cards with a bold lead, detail text and one action) vs. B
|
|
|
31
31
|
- Demo content: the three entries carry `kind`, the hours description
|
|
32
32
|
keeps only the exceptions (Saturday, closed Tuesday), the reservation
|
|
33
33
|
card gets a call button.
|
|
34
|
-
-
|
|
35
|
-
branch `docs/storefront-info-cards` stacked on
|
|
36
|
-
`docs/storefront-hero-title`).
|
|
34
|
+
- Docs: https://shopbite.de/docs/storefront/content (DE/EN).
|
|
37
35
|
|
|
38
36
|
## Verification
|
|
39
37
|
|
|
@@ -6,7 +6,7 @@ Follow-up to `2026-09-10-issue-273-performance-media.md` (PR #308).
|
|
|
6
6
|
|
|
7
7
|
- Object storage media (demo and La Fattoria) send
|
|
8
8
|
`public, max-age=31536000, immutable`: done on the buckets.
|
|
9
|
-
-
|
|
9
|
+
- The docs on shopbite.de cover poster, video size, thumbnails and the bucket header.
|
|
10
10
|
- Remaining requests without a useful cache lifetime on demo.shopbite.de:
|
|
11
11
|
- files from `public/` (`/hero-poster.webp`, `/favicon.ico`, `/light/Logo.png`):
|
|
12
12
|
no `Cache-Control` at all. Nitro only adds one for public asset dirs with
|
|
@@ -14,7 +14,7 @@ Container logs in OpenObserve (`docker_logs`, 2026-09-19 to 2026-09-21):
|
|
|
14
14
|
| ----------------------- | ------------------------- |
|
|
15
15
|
| `lafattoria-storefront` | ~2,500 |
|
|
16
16
|
| `shopbite-storefront` | 565 |
|
|
17
|
-
|
|
|
17
|
+
| shopbite.de website | 423 (same pattern) |
|
|
18
18
|
|
|
19
19
|
`fatal` cannot simply be dropped: Nuxt's root component
|
|
20
20
|
(`nuxt/dist/app/components/nuxt-root.vue`, `onErrorCaptured`) shows the error
|
|
@@ -30,13 +30,13 @@ demos (`leads/demo_create.py` in the monorepo) made the sameness obvious.
|
|
|
30
30
|
title, description; all optional, German defaults in the components),
|
|
31
31
|
`gallery` optional. Existing `index.yml` files keep working; an old
|
|
32
32
|
`marquee` block is ignored by Zod.
|
|
33
|
-
-
|
|
33
|
+
- Docs: https://shopbite.de/docs/storefront/content (DE/EN).
|
|
34
34
|
|
|
35
35
|
## Verification
|
|
36
36
|
|
|
37
37
|
- `HomeMenuCategories.test.ts`: tiles with photo/icon, cap and "all" tile,
|
|
38
38
|
empty state. Prettier, ESLint, typecheck and the unit suite pass.
|
|
39
|
-
- Production build against a
|
|
39
|
+
- Production build against a demo sales channel: tiles show the
|
|
40
40
|
category photos, the grid the eight top sellers, quick view opens.
|
|
41
41
|
|
|
42
42
|
## Follow-ups
|
|
@@ -18,4 +18,4 @@ As of 2026-10-05, branch `feature/401-restaurant-schema-ordering`. Part of the A
|
|
|
18
18
|
|
|
19
19
|
Production build against the demo backend with the new env variables: the home page `Restaurant` node carries `geo`, both delivery areas, `acceptsReservations: true`, `paymentAccepted: "Nachnahme"`, `currenciesAccepted: "EUR"` and the `OrderAction` with pickup and own delivery. Without the new variables only `paymentAccepted`, `currenciesAccepted` and `potentialAction` (without `deliveryMethod`) are added. Unit + nuxt tests, typecheck, ESLint green.
|
|
20
20
|
|
|
21
|
-
Docs:
|
|
21
|
+
Docs: https://shopbite.de/docs/storefront/configuration (DE/EN), including the note that `NUXT_PUBLIC_SITE_CUISINE` is a cuisine name: La Fattoria sets `italienische`, which produces "italienische in Obertshausen" in its meta description.
|
package/modules/theme.ts
CHANGED
|
@@ -68,7 +68,7 @@ function registerFonts(preset: ThemePreset, nuxt: Nuxt) {
|
|
|
68
68
|
* browsers download only the faces the active preset uses) and makes the
|
|
69
69
|
* configured preset the default of `runtimeConfig.public.shopBite.themePreset`.
|
|
70
70
|
* One build can so serve every preset: `NUXT_PUBLIC_SHOP_BITE_THEME_PRESET`
|
|
71
|
-
* switches it at runtime (
|
|
71
|
+
* switches it at runtime (one image can run several restaurants),
|
|
72
72
|
* plugins/theme-preset.ts sets `data-preset` on `<html>`.
|
|
73
73
|
*/
|
|
74
74
|
export default defineNuxtModule<ShopBiteThemeOptions>({
|
package/nuxt.config.ts
CHANGED
|
@@ -74,6 +74,19 @@ export default defineNuxtConfig({
|
|
|
74
74
|
listing: 86400,
|
|
75
75
|
variant: 3600,
|
|
76
76
|
category: 86400,
|
|
77
|
+
// Layout data of every page (navigation, SEO URLs, breadcrumbs,
|
|
78
|
+
// plugin config, hours): the server renders it from these caches,
|
|
79
|
+
// so a request (also a 404) does not ask Shopware for it again.
|
|
80
|
+
navigation: 86400,
|
|
81
|
+
// SEO URL matches and the list of known category paths: a new or
|
|
82
|
+
// renamed section must not 404 for long without a purge.
|
|
83
|
+
seoUrl: 600,
|
|
84
|
+
paymentMethods: 3600,
|
|
85
|
+
// Carries the checkout switch, so short; the browser reloads it
|
|
86
|
+
// from Shopware after hydration (useLiveShopData).
|
|
87
|
+
config: 60,
|
|
88
|
+
businessHours: 300,
|
|
89
|
+
holidays: 300,
|
|
77
90
|
},
|
|
78
91
|
menuCategoryId: "",
|
|
79
92
|
searchFallbackCategoryId: "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbite-de/storefront",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"main": "nuxt.config.ts",
|
|
5
5
|
"description": "Shopware storefront for food delivery shops",
|
|
6
6
|
"keywords": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@nuxt/content": "3.16.
|
|
21
|
+
"@nuxt/content": "3.16.2",
|
|
22
22
|
"@nuxt/fonts": "^0.14.0",
|
|
23
23
|
"@nuxt/image": "^2.1.0",
|
|
24
24
|
"@nuxt/scripts": "1.3.12",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@axe-core/playwright": "^4.13.0",
|
|
45
45
|
"@nuxt/devtools-kit": "^3.4.2",
|
|
46
46
|
"@nuxt/eslint": "^1.17.0",
|
|
47
|
-
"@nuxt/hints": "1.1.
|
|
47
|
+
"@nuxt/hints": "1.1.5",
|
|
48
48
|
"@nuxt/test-utils": "^4.3.2",
|
|
49
49
|
"@playwright/test": "^1.63.0",
|
|
50
50
|
"@types/js-cookie": "^3.0.6",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@typescript-eslint/eslint-plugin": "^8.70.1",
|
|
53
53
|
"@typescript-eslint/parser": "^8.70.1",
|
|
54
54
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
55
|
-
"@vitest/ui": "5.0.
|
|
55
|
+
"@vitest/ui": "5.0.5",
|
|
56
56
|
"@vue/compiler-dom": "^3.5.43",
|
|
57
57
|
"@vue/server-renderer": "^3.5.43",
|
|
58
58
|
"@vue/test-utils": "^2.5.1",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"tailwindcss": "^4.3.3",
|
|
67
67
|
"typescript": "^6.0.3",
|
|
68
68
|
"vitest": "^5.0.1",
|
|
69
|
-
"vue-tsc": "3.3.
|
|
69
|
+
"vue-tsc": "3.3.13"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|
|
72
72
|
"build": "nuxt build",
|
|
@@ -5,13 +5,16 @@ const Body = z
|
|
|
5
5
|
.object({
|
|
6
6
|
products: z.array(Id).max(1000).optional(),
|
|
7
7
|
categories: z.array(Id).max(1000).optional(),
|
|
8
|
+
// only the layout data (hours, closing days, checkout switch, ...)
|
|
9
|
+
layout: z.boolean().optional(),
|
|
8
10
|
})
|
|
9
11
|
.default({});
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
|
-
* Empties the Store API caches after the backoffice changed the menu (#484)
|
|
13
|
-
*
|
|
14
|
-
* off. An empty
|
|
14
|
+
* Empties the Store API caches after the backoffice changed the menu (#484)
|
|
15
|
+
* or the shop settings (`{ "layout": true }`). Protected by
|
|
16
|
+
* NUXT_CACHE_PURGE_SECRET; without the variable the route is off. An empty
|
|
17
|
+
* body purges everything.
|
|
15
18
|
*/
|
|
16
19
|
export default defineEventHandler(async (event) => {
|
|
17
20
|
const secret = useRuntimeConfig(event).cachePurgeSecret;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { components } from "~~/api-types/storeApiTypes";
|
|
2
|
+
import { createResilientLoader } from "../../utils/backoff";
|
|
3
|
+
|
|
4
|
+
const Id = /^[0-9a-f]{32}$/i;
|
|
5
|
+
type Breadcrumb = components["schemas"]["BreadcrumbCollection"];
|
|
6
|
+
|
|
7
|
+
// only real breadcrumbs are remembered, not the empty list of random ids
|
|
8
|
+
const load = createResilientLoader<Breadcrumb>((crumbs) => crumbs.length > 0);
|
|
9
|
+
|
|
10
|
+
/** Breadcrumb of a menu section (Category/Breadcrumb.vue). */
|
|
11
|
+
export default defineCachedEventHandler(
|
|
12
|
+
async (event): Promise<components["schemas"]["BreadcrumbCollection"]> => {
|
|
13
|
+
const categoryId = getRouterParam(event, "categoryId") ?? "";
|
|
14
|
+
if (!Id.test(categoryId)) throw createError({ statusCode: 400 });
|
|
15
|
+
|
|
16
|
+
const breadcrumb = await load(categoryId, () =>
|
|
17
|
+
storeApiGet<Breadcrumb>(`/breadcrumb/${categoryId}`, {
|
|
18
|
+
query: { type: "category" },
|
|
19
|
+
}),
|
|
20
|
+
);
|
|
21
|
+
// Shopware answers an unknown id with an empty list; a 404 is not
|
|
22
|
+
// cached, so random ids cannot fill the cache.
|
|
23
|
+
if (!breadcrumb?.length) throw createError({ statusCode: 404 });
|
|
24
|
+
return breadcrumb;
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
maxAge: useRuntimeConfig().public.shopBite.cacheTtl.category,
|
|
28
|
+
name: "breadcrumb",
|
|
29
|
+
getKey: (event) => `breadcrumb-${getRouterParam(event, "categoryId")}`,
|
|
30
|
+
},
|
|
31
|
+
);
|