Files
wp-headless/wp-content/themes/moonshine/app/utils/acf-link.ts
Pascal Martineau 9bb09b89d9
All checks were successful
Deployment / wordpress (push) Successful in 6s
Deployment / nuxt (push) Successful in 58s
feat: Replace eslint => oxlint + oxfmt
2026-02-01 22:06:16 -05:00

18 lines
419 B
TypeScript

import type { AcfLinkFragment } from "#graphql/operations";
import * as z from "zod";
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;
}
}