generated from pascalmartineau/wp-skeleton
feat: Virtual page redirect, breadcrumb & menu items
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m5s
All checks were successful
Deploy WordPress and Nuxt / deploy (push) Successful in 1m5s
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
fragment ThePage on Page {
|
||||
title
|
||||
template {
|
||||
__typename
|
||||
}
|
||||
children {
|
||||
nodes {
|
||||
uri
|
||||
}
|
||||
}
|
||||
groupPostPage {
|
||||
sections {
|
||||
...TheSection
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
import type { ThePageFragment } from "#graphql-operations";
|
||||
|
||||
const props = defineProps<ThePageFragment>();
|
||||
|
||||
if (props.template?.__typename === "Template_VirtualPage") {
|
||||
await navigateTo(props.children?.nodes[0]?.uri || "/");
|
||||
}
|
||||
|
||||
useSeoMeta({ title: props.title });
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
export async function useSiteOptions() {
|
||||
const { data } = await useAsyncGraphqlQuery("siteOptions", {}, { graphqlCaching: { client: true } });
|
||||
if (data.value?.errors?.length || !data.value?.data.siteOptions?.groupCcat) {
|
||||
throw createError({ statusCode: 500, message: "Erreur lors de la récupération des options du site" });
|
||||
const { data, error } = await useAsyncGraphqlQuery("siteOptions", {}, { graphqlCaching: { client: true } });
|
||||
if (error.value) {
|
||||
throw createError({ statusCode: 500, statusMessage: "Erreur interne", message: error.value.message });
|
||||
}
|
||||
if (data.value?.errors.length) {
|
||||
throw createError({ statusCode: 500, statusMessage: "Erreur interne", message: data.value.errors.map((error) => error.message).join("\n") });
|
||||
}
|
||||
if (!data.value?.data.siteOptions?.groupCcat) {
|
||||
throw createError({ statusCode: 500, statusMessage: "Erreur interne", message: "Options du site invalides." });
|
||||
}
|
||||
return { ...data.value?.data.siteOptions?.groupCcat };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user