From 2cfc1a00477c18a4341053e2d070e215eda220f3 Mon Sep 17 00:00:00 2001 From: Pascal Martineau Date: Fri, 30 Jan 2026 15:43:49 -0500 Subject: [PATCH] feat: parseAcfLink --- .../app/components/acf/AcfMedia.fragment.gql | 8 ++------ .../components/auth/AuthConnexionButton.vue | 20 ------------------- .../themes/moonshine/app/utils/acf-link.ts | 18 +++++++++++++++++ wp-content/themes/moonshine/nuxt.config.ts | 1 + 4 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 wp-content/themes/moonshine/app/components/auth/AuthConnexionButton.vue create mode 100644 wp-content/themes/moonshine/app/utils/acf-link.ts diff --git a/wp-content/themes/moonshine/app/components/acf/AcfMedia.fragment.gql b/wp-content/themes/moonshine/app/components/acf/AcfMedia.fragment.gql index e5e9138..7cce4d9 100644 --- a/wp-content/themes/moonshine/app/components/acf/AcfMedia.fragment.gql +++ b/wp-content/themes/moonshine/app/components/acf/AcfMedia.fragment.gql @@ -1,9 +1,5 @@ fragment AcfMedia on GroupAbstractMedia_Fields { - image { - node { - ...AcfImage - } - } + image { node { ... AcfImage } } aspectRatio objectFit -} \ No newline at end of file +} diff --git a/wp-content/themes/moonshine/app/components/auth/AuthConnexionButton.vue b/wp-content/themes/moonshine/app/components/auth/AuthConnexionButton.vue deleted file mode 100644 index 29fe333..0000000 --- a/wp-content/themes/moonshine/app/components/auth/AuthConnexionButton.vue +++ /dev/null @@ -1,20 +0,0 @@ - - - diff --git a/wp-content/themes/moonshine/app/utils/acf-link.ts b/wp-content/themes/moonshine/app/utils/acf-link.ts new file mode 100644 index 0000000..9af48d8 --- /dev/null +++ b/wp-content/themes/moonshine/app/utils/acf-link.ts @@ -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; + +export function parseAcfLink(data?: Partial) { + try { + return acfLinkSchema.parse(data); + } + catch { + return undefined; + } +} diff --git a/wp-content/themes/moonshine/nuxt.config.ts b/wp-content/themes/moonshine/nuxt.config.ts index 9311783..71fbbb3 100644 --- a/wp-content/themes/moonshine/nuxt.config.ts +++ b/wp-content/themes/moonshine/nuxt.config.ts @@ -119,4 +119,5 @@ export default defineNuxtConfig({ componentPrefix: "Svg", defaultImport: "component", }, + });