@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.
@@ -118,7 +118,7 @@ const moreThanOneFilterAndOption = computed<boolean>(
118
118
  <UPage>
119
119
  <template #left>
120
120
  <UPageAside>
121
- <NavigationDesktopLeft2 />
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 mt-8 mb-3 pb-2">Filter</h2>
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 { mainNavigation } = useNavigation(false);
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 (mainNavigation.value ?? []).map(mapCategoryToNavItem);
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 mt-8 mb-3 pb-2">Speisekarte</h2>
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
+ }
@@ -3,7 +3,7 @@
3
3
  <template>
4
4
  <UPage>
5
5
  <div class="sticky top-16 left-0 z-20 w-full backdrop-blur-md rounded-md">
6
- <NavigationMobileTop2 :should-skip-first-level="true" />
6
+ <NavigationMobileTop />
7
7
  </div>
8
8
  <slot />
9
9
  </UPage>
@@ -2,8 +2,9 @@
2
2
  import type { Schemas } from "#shopware";
3
3
 
4
4
  definePageMeta({
5
- layout: "listing2",
5
+ layout: "listing",
6
6
  });
7
+
7
8
  const { clearBreadcrumbs } = useBreadcrumbs();
8
9
  const { resolvePath } = useNavigationSearch();
9
10
  const route = useRoute();
package/nuxt.config.ts CHANGED
@@ -55,6 +55,7 @@ export default defineNuxtConfig({
55
55
  geoapifyApiKey: "",
56
56
  public: {
57
57
  shopBite: {
58
+ menuCategoryId: "",
58
59
  feature: {
59
60
  multiChannel: "",
60
61
  secureKey: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -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>