diff --git a/.changeset/mighty-icons-try.md b/.changeset/mighty-icons-try.md new file mode 100644 index 000000000000..86965b765315 --- /dev/null +++ b/.changeset/mighty-icons-try.md @@ -0,0 +1,5 @@ +--- +"@astrojs/rss": patch +--- + +Fixes `rssSchema` definition to allow calling standard zod object methods (like `extend`) diff --git a/packages/astro-rss/src/schema.ts b/packages/astro-rss/src/schema.ts index 788fe86fb3be..773d39cf2020 100644 --- a/packages/astro-rss/src/schema.ts +++ b/packages/astro-rss/src/schema.ts @@ -1,6 +1,8 @@ import { z } from 'astro/zod'; -const sharedSchema = z.object({ +export const rssSchema = z.object({ + title: z.string().optional(), + description: z.string().optional(), pubDate: z .union([z.string(), z.number(), z.date()]) .optional() @@ -20,19 +22,7 @@ const sharedSchema = z.object({ .optional(), link: z.string().optional(), content: z.string().optional(), -}); - -export const rssSchema = z.union([ - z - .object({ - title: z.string(), - description: z.string().optional(), - }) - .merge(sharedSchema), - z - .object({ - title: z.string().optional(), - description: z.string(), - }) - .merge(sharedSchema), -]); +}).refine(val => val.title || val.description, { + message: "At least title or description must be provided.", + path: ["title", "description"] +}) \ No newline at end of file