feat: Initial NodeByUri logic and frontend

This commit is contained in:
2026-01-13 21:25:20 -05:00
parent 5bda835566
commit 688c4e36b3
10 changed files with 291 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
fragment BuilderSections on GroupAbstractBuilder_Fields {
sections {
__typename
... on GroupAbstractBuilderSectionsTextBlockLayout {
... SectionTextBlock
}
}
}

View File

@@ -0,0 +1,9 @@
<script setup lang="ts">
import type { BuilderSectionsFragment } from "#graphql/typed-documents";
defineProps<BuilderSectionsFragment>();
</script>
<template>
<pre>{{ sections }}</pre>
</template>

View File

@@ -0,0 +1,6 @@
fragment NodePage on Page {
title
groupPostPage {
... BuilderSections
}
}

View File

@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { NodePageFragment } from "#graphql/typed-documents";
defineProps<NodePageFragment>();
</script>
<template>
<div id="node-page">
<h1 class="font-bold text-4xl">
{{ title }}
</h1>
<BuilderSections v-bind="groupPostPage" />
</div>
</template>

View File

@@ -0,0 +1,3 @@
fragment SectionTextBlock on GroupAbstractBuilderSectionsTextBlockLayout {
content
}

View File

@@ -0,0 +1,9 @@
<script setup lang="ts">
import type { SectionTextBlockFragment } from "#graphql/typed-documents";
defineProps<SectionTextBlockFragment>();
</script>
<template>
<div v-html="content" />
</template>

View File

@@ -0,0 +1,8 @@
query NodeByUri($uri: String!) {
nodeByUri(uri: $uri) {
__typename
... on Page {
... NodePage
}
}
}

View File

@@ -1,6 +1,19 @@
<script setup lang="ts">
const { path: uri } = useRoute();
const { data } = await useGraphQLQuery("NodeByUri", { uri });
// Resolve and validate Node component
if (!data.value.nodeByUri) {
throw createError({ statusCode: 404, message: `La page demandée est introuvable: ${uri}` });
}
const componentName = `Node${data.value.nodeByUri.__typename}`;
if (!useNuxtApp().vueApp.component(componentName)) {
throw createError({ statusCode: 404, message: `La page demandée ne peut pas être affichée correctement: ${componentName}` });
}
</script>
<template>
<div id="page-node-from-uri" />
<div v-if="data.nodeByUri" id="page-node-from-uri">
<Component :is="componentName" v-bind="data.nodeByUri" />
</div>
</template>