feat: parseAcfLink

This commit is contained in:
2026-01-30 15:43:49 -05:00
parent 98e8d971e8
commit 2cfc1a0047
4 changed files with 21 additions and 26 deletions

View File

@@ -1,9 +1,5 @@
fragment AcfMedia on GroupAbstractMedia_Fields { fragment AcfMedia on GroupAbstractMedia_Fields {
image { image { node { ... AcfImage } }
node {
...AcfImage
}
}
aspectRatio aspectRatio
objectFit objectFit
} }

View File

@@ -1,20 +0,0 @@
<script setup lang="ts">
const { isLoggedIn } = useAuth();
const attrs = computed(() => {
return isLoggedIn.value
? {
label: "Déconnexion",
icon: "i-lucide-log-out",
}
: {
label: "Connexion",
icon: "i-lucide-log-in",
};
});
</script>
<template>
<AuthState>
<UButton to="/connexion" v-bind="attrs" color="neutral" />
</AuthState>
</template>

View File

@@ -0,0 +1,18 @@
import * as z from "zod";
import type { AcfLinkFragment } from "#graphql/operations";
const acfLinkSchema = z.object({
title: z.string(),
url: z.string(),
target: z.string().optional().default(""),
});
export type AcfLinkOutput = z.infer<typeof acfLinkSchema>;
export function parseAcfLink(data?: Partial<AcfLinkFragment>) {
try {
return acfLinkSchema.parse(data);
}
catch {
return undefined;
}
}

View File

@@ -119,4 +119,5 @@ export default defineNuxtConfig({
componentPrefix: "Svg", componentPrefix: "Svg",
defaultImport: "component", defaultImport: "component",
}, },
}); });