refactor: breadcrumbs stuff

This commit is contained in:
2025-09-16 13:51:03 -04:00
parent 4cff390f41
commit 3d1e311fef
6 changed files with 91 additions and 97 deletions

View File

@@ -4,7 +4,7 @@ query nodeByUri($uri: String!) {
id
breadcrumbs {
label
uri
to
}
... on Page {
...ThePage

View File

@@ -17,11 +17,6 @@ import {
TheResource,
} from "#components";
interface BreadcrumbItem {
label: string;
to?: string;
}
export async function useNodeByUri() {
const route = useRoute();
const uri = computed(() => route.path);
@@ -30,18 +25,7 @@ export async function useNodeByUri() {
throw createError({ statusCode: 500, message: "Erreur lors de la récupération du contenu", fatal: true });
}
const node = data.value?.data.nodeByUri;
const breadcrumbs: BreadcrumbItem[] = [];
if (node?.breadcrumbs) {
breadcrumbs.push(
...node.breadcrumbs
.filter((item: any) => item.label)
.map((item: any) => ({
label: item.label,
to: item.uri || undefined,
})),
);
}
const breadcrumbs = node?.breadcrumbs?.map(({ label, to }) => ({ label, to: to || undefined })) || [];
switch (node?.__typename) {
case "Page":