feat: more modern way to use 'reference' to get authors

This commit is contained in:
grassblock 2025-06-06 22:50:36 +08:00
parent 9ff40d1e9e
commit 9ecf25f3ab
4 changed files with 21 additions and 12 deletions

View file

@ -1,4 +1,4 @@
import { z } from 'astro:content';
import { z, reference } from 'astro:content';
export const posts = ({ image }) => z.object({
title: z.string(),
@ -8,5 +8,5 @@ export const posts = ({ image }) => z.object({
categories: z.array(z.string()).default(['uncategorized']),
tags: z.array(z.string()).optional(),
cover: image().optional(),
author: z.string().optional(),
author: reference('authors').optional(),
});