generated from pascalmartineau/wp-skeleton
refactor: breadcrumbs stuff
This commit is contained in:
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user