diff --git a/wp-content/themes/headless/app/components/site/SiteHeader.vue b/wp-content/themes/headless/app/components/site/SiteHeader.vue
index 9fa8da7..5402038 100644
--- a/wp-content/themes/headless/app/components/site/SiteHeader.vue
+++ b/wp-content/themes/headless/app/components/site/SiteHeader.vue
@@ -1,3 +1,7 @@
+
+
@@ -5,5 +9,9 @@
+
+
+
+
diff --git a/wp-content/themes/headless/app/composables/useAuthConnexion.ts b/wp-content/themes/headless/app/composables/useAuthConnexion.ts
index 5d01615..76ce7cb 100644
--- a/wp-content/themes/headless/app/composables/useAuthConnexion.ts
+++ b/wp-content/themes/headless/app/composables/useAuthConnexion.ts
@@ -1,4 +1,4 @@
-import { delay } from "es-toolkit/promise";
+import { delay } from "es-toolkit";
import type { ButtonProps } from "@nuxt/ui";
import type { FormSubmitEvent } from "@nuxt/ui";
diff --git a/wp-content/themes/headless/app/composables/useMenuItems.gql b/wp-content/themes/headless/app/composables/useMenuItems.gql
new file mode 100644
index 0000000..41c66dd
--- /dev/null
+++ b/wp-content/themes/headless/app/composables/useMenuItems.gql
@@ -0,0 +1,19 @@
+fragment MenuItem on MenuItem {
+ id
+ label @nullToUndefined
+ to: path @nullToUndefined
+ target
+}
+
+query MenuItems($location: MenuLocationEnum) {
+ menuItems(where: { location: $location, parentDatabaseId: 0 }) {
+ nodes {
+ ...MenuItem
+ childItems {
+ nodes {
+ ...MenuItem
+ }
+ }
+ }
+ }
+}
diff --git a/wp-content/themes/headless/app/composables/useMenuItems.ts b/wp-content/themes/headless/app/composables/useMenuItems.ts
new file mode 100644
index 0000000..650eb66
--- /dev/null
+++ b/wp-content/themes/headless/app/composables/useMenuItems.ts
@@ -0,0 +1,10 @@
+import type { MenuItemsVariables } from "#graphql/types";
+
+export const useMenuItems = (variables: MenuItemsVariables) =>
+ useAsyncGraphQLQuery("MenuItems", variables, {
+ transform: ({ menuItems }) =>
+ extractNodes(menuItems).map(({ childItems, ...menuItem }) => ({
+ ...menuItem,
+ children: extractNodes(childItems),
+ })),
+ });
diff --git a/wp-content/themes/headless/server/utils/auth.ts b/wp-content/themes/headless/server/utils/auth.ts
index 3275ce2..7d0ff01 100644
--- a/wp-content/themes/headless/server/utils/auth.ts
+++ b/wp-content/themes/headless/server/utils/auth.ts
@@ -43,10 +43,10 @@ export async function handleLogout(event: H3Event) {
* @param user The AuthUserFragment containing user data from the GraphQL response
* @returns A User object with the expected structure for nuxt-auth-utils, including an array of role names
*/
-function getAuthUser(user: AuthUserFragment) {
+function getAuthUser({ roles, ...user }: AuthUserFragment) {
return {
...user,
- roles: user.roles.nodes.map(({ name }) => name) || [],
+ roles: extractNodes(roles).map(({ name }) => name),
};
}
diff --git a/wp-content/themes/headless/shared/utils/graphql.ts b/wp-content/themes/headless/shared/utils/graphql.ts
new file mode 100644
index 0000000..e88dbf2
--- /dev/null
+++ b/wp-content/themes/headless/shared/utils/graphql.ts
@@ -0,0 +1,4 @@
+// Helper: Extracts nodes from a GraphQL connection object, returning an empty array if nodes are absent.
+export function extractNodes(connection: { nodes?: T[] } | null | undefined): T[] {
+ return connection?.nodes ?? [];
+}