@shopbite-de/storefront 1.15.0 → 1.16.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/app/components/Category/Listing.vue +2 -2
- package/app/components/Navigation/{DesktopLeft2.vue → DesktopLeft.vue} +3 -3
- package/app/components/Navigation/MobileTop.vue +24 -0
- package/app/composables/useNavigation.ts +30 -0
- package/app/composables/useNavigationSearch.ts +68 -0
- package/app/layouts/{listing2.vue → listing.vue} +1 -1
- package/app/pages/speisekarte/[...all].vue +2 -1
- package/nuxt.config.ts +1 -0
- package/package.json +1 -1
- package/app/components/Navigation/MobileTop2.vue +0 -61
|
@@ -118,7 +118,7 @@ const moreThanOneFilterAndOption = computed<boolean>(
|
|
|
118
118
|
<UPage>
|
|
119
119
|
<template #left>
|
|
120
120
|
<UPageAside>
|
|
121
|
-
<
|
|
121
|
+
<NavigationDesktopLeft />
|
|
122
122
|
</UPageAside>
|
|
123
123
|
</template>
|
|
124
124
|
|
|
@@ -212,7 +212,7 @@ const moreThanOneFilterAndOption = computed<boolean>(
|
|
|
212
212
|
<template #right>
|
|
213
213
|
<UPageAside>
|
|
214
214
|
<div v-if="moreThanOneFilterAndOption" class="flex flex-col gap-4">
|
|
215
|
-
<h2 class="text-3xl md:text-4xl
|
|
215
|
+
<h2 class="text-3xl md:text-4xl mb-3 pb-2">Filter</h2>
|
|
216
216
|
<div
|
|
217
217
|
v-for="filter in propertyFilters"
|
|
218
218
|
:key="filter.id"
|
|
@@ -3,7 +3,7 @@ import type { NavigationMenuItem } from "@nuxt/ui";
|
|
|
3
3
|
import type { Schemas } from "#shopware";
|
|
4
4
|
import { useNavigation } from "~/composables/useNavigation";
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const { menuCardNavigation } = useNavigation(true);
|
|
7
7
|
|
|
8
8
|
const mapCategoryToNavItem = (
|
|
9
9
|
category: Schemas["Category"],
|
|
@@ -21,13 +21,13 @@ const mapCategoryToNavItem = (
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const navItems = computed<NavigationMenuItem[]>(() => {
|
|
24
|
-
return (
|
|
24
|
+
return (menuCardNavigation.value ?? []).map(mapCategoryToNavItem);
|
|
25
25
|
});
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
28
|
<template>
|
|
29
29
|
<div>
|
|
30
|
-
<h2 class="text-3xl md:text-4xl
|
|
30
|
+
<h2 class="text-3xl md:text-4xl mb-3 pb-2">Speisekarte</h2>
|
|
31
31
|
<UNavigationMenu
|
|
32
32
|
variant="link"
|
|
33
33
|
orientation="vertical"
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useNavigation } from "~/composables/useNavigation";
|
|
3
|
+
|
|
4
|
+
const { menuCardMenu } = useNavigation(true);
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<template>
|
|
8
|
+
<UNavigationMenu
|
|
9
|
+
class="lg:hidden"
|
|
10
|
+
orientation="horizontal"
|
|
11
|
+
:items="menuCardMenu"
|
|
12
|
+
:ui="{
|
|
13
|
+
list: 'overflow-x-auto',
|
|
14
|
+
item: 'flex-shrink-0',
|
|
15
|
+
}"
|
|
16
|
+
>
|
|
17
|
+
<template #list-leading>
|
|
18
|
+
<UIcon name="i-lucide-chevron-left" class="size-8" />
|
|
19
|
+
</template>
|
|
20
|
+
<template #list-trailing>
|
|
21
|
+
<UIcon name="i-lucide-chevron-right" class="size-8" />
|
|
22
|
+
</template>
|
|
23
|
+
</UNavigationMenu>
|
|
24
|
+
</template>
|
|
@@ -4,6 +4,10 @@ import type { Schemas } from "#shopware";
|
|
|
4
4
|
|
|
5
5
|
export function useNavigation(withChildren: boolean | undefined) {
|
|
6
6
|
const { apiClient } = useShopwareContext();
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
const menuCategoryId = computed(
|
|
9
|
+
() => config.public.shopBite.menuCategoryId ?? "main-navigation",
|
|
10
|
+
);
|
|
7
11
|
|
|
8
12
|
const criteria = encodeForQuery({
|
|
9
13
|
includes: {
|
|
@@ -77,10 +81,36 @@ export function useNavigation(withChildren: boolean | undefined) {
|
|
|
77
81
|
return footerNavigation.value?.map(mapCategoryToMenuItem);
|
|
78
82
|
});
|
|
79
83
|
|
|
84
|
+
const { data: menuCardNavigation } = useAsyncData(
|
|
85
|
+
"menu-category",
|
|
86
|
+
async () => {
|
|
87
|
+
const response = await apiClient.invoke(
|
|
88
|
+
"readNavigationGet get /navigation/{activeId}/{rootId}",
|
|
89
|
+
{
|
|
90
|
+
query: { _criteria: criteria },
|
|
91
|
+
pathParams: {
|
|
92
|
+
activeId: "main-navigation",
|
|
93
|
+
rootId: menuCategoryId.value,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
return response.data;
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const menuCardMenu = computed<NavigationMenuItem[]>(() => {
|
|
103
|
+
if (!menuCardNavigation.value) return [];
|
|
104
|
+
|
|
105
|
+
return menuCardNavigation.value?.map(mapCategoryToMenuItem);
|
|
106
|
+
});
|
|
107
|
+
|
|
80
108
|
return {
|
|
81
109
|
mainNavigation,
|
|
82
110
|
mainMenu,
|
|
83
111
|
footerNavigation,
|
|
84
112
|
footerMenu,
|
|
113
|
+
menuCardNavigation,
|
|
114
|
+
menuCardMenu,
|
|
85
115
|
};
|
|
86
116
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useSessionContext, useShopwareContext } from "#imports";
|
|
2
|
+
import type { Schemas } from "#shopware";
|
|
3
|
+
import { encodeForQuery } from "@shopware/api-client/helpers";
|
|
4
|
+
|
|
5
|
+
export type UseNavigationSearchReturn = {
|
|
6
|
+
/**
|
|
7
|
+
* Get {@link SeoUrl} entity for given path
|
|
8
|
+
* @example resolvePath("/my-category/my-product") or resolvePath("/") for home page
|
|
9
|
+
*/
|
|
10
|
+
resolvePath(path: string): Promise<Schemas["SeoUrl"] | null>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Composable to get search for SeoUrl entity for given path.
|
|
15
|
+
* @public
|
|
16
|
+
* @category Navigation & Routing
|
|
17
|
+
*/
|
|
18
|
+
export function useNavigationSearch(): UseNavigationSearchReturn {
|
|
19
|
+
const { apiClient } = useShopwareContext();
|
|
20
|
+
const { sessionContext } = useSessionContext();
|
|
21
|
+
|
|
22
|
+
async function resolvePath(path: string): Promise<Schemas["SeoUrl"] | null> {
|
|
23
|
+
if (path === "/") {
|
|
24
|
+
// please ignore optional chaining for salesChannel object as it's always present (type definition issue)
|
|
25
|
+
const categoryId =
|
|
26
|
+
sessionContext.value?.salesChannel?.navigationCategoryId;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
routeName: "frontend.navigation.page",
|
|
30
|
+
foreignKey: categoryId,
|
|
31
|
+
} as Schemas["SeoUrl"];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isTechnicalUrl =
|
|
35
|
+
path.startsWith("/navigation/") ||
|
|
36
|
+
path.startsWith("/detail/") ||
|
|
37
|
+
path.startsWith("/landingPage/");
|
|
38
|
+
|
|
39
|
+
// remove leading slash in case of seo url or remove trailing slash in case of technical url
|
|
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;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
resolvePath,
|
|
67
|
+
};
|
|
68
|
+
}
|
package/nuxt.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { useNavigation } from "~/composables/useNavigation";
|
|
3
|
-
import type { NavigationMenuItem } from "@nuxt/ui";
|
|
4
|
-
import type { Schemas } from "#shopware";
|
|
5
|
-
|
|
6
|
-
type Category = Schemas["Category"];
|
|
7
|
-
|
|
8
|
-
const props = withDefaults(
|
|
9
|
-
defineProps<{
|
|
10
|
-
shouldSkipFirstLevel?: boolean;
|
|
11
|
-
}>(),
|
|
12
|
-
{
|
|
13
|
-
shouldSkipFirstLevel: false,
|
|
14
|
-
},
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const { mainNavigation } = useNavigation(true);
|
|
18
|
-
|
|
19
|
-
const navItems = computed<NavigationMenuItem[]>(() => {
|
|
20
|
-
const elements = mainNavigation.value ?? [];
|
|
21
|
-
|
|
22
|
-
const mapCategoryRecursively = (category: Category): NavigationMenuItem => {
|
|
23
|
-
const hasChildren = (category.children?.length ?? 0) > 0;
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
label: category.translated?.name ?? "",
|
|
27
|
-
to: hasChildren ? undefined : category.seoUrl,
|
|
28
|
-
children: hasChildren
|
|
29
|
-
? category.children!.map(mapCategoryRecursively)
|
|
30
|
-
: undefined,
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
if (props.shouldSkipFirstLevel) {
|
|
35
|
-
return elements
|
|
36
|
-
.flatMap((item: Category) => item.children ?? [])
|
|
37
|
-
.map(mapCategoryRecursively);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return elements.map(mapCategoryRecursively);
|
|
41
|
-
});
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
<template>
|
|
45
|
-
<UNavigationMenu
|
|
46
|
-
class="lg:hidden"
|
|
47
|
-
orientation="horizontal"
|
|
48
|
-
:items="navItems"
|
|
49
|
-
:ui="{
|
|
50
|
-
list: 'overflow-x-auto',
|
|
51
|
-
item: 'flex-shrink-0',
|
|
52
|
-
}"
|
|
53
|
-
>
|
|
54
|
-
<template #list-leading>
|
|
55
|
-
<UIcon name="i-lucide-chevron-left" class="size-8" />
|
|
56
|
-
</template>
|
|
57
|
-
<template #list-trailing>
|
|
58
|
-
<UIcon name="i-lucide-chevron-right" class="size-8" />
|
|
59
|
-
</template>
|
|
60
|
-
</UNavigationMenu>
|
|
61
|
-
</template>
|