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

@@ -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;
}
}