summaryrefslogtreecommitdiff
path: root/packages/astro-rss/src/schema.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/astro-rss/src/schema.ts')
-rw-r--r--packages/astro-rss/src/schema.ts26
1 files changed, 21 insertions, 5 deletions
diff --git a/packages/astro-rss/src/schema.ts b/packages/astro-rss/src/schema.ts
index 98aa35f81..788fe86fb 100644
--- a/packages/astro-rss/src/schema.ts
+++ b/packages/astro-rss/src/schema.ts
@@ -1,12 +1,11 @@
import { z } from 'astro/zod';
-export const rssSchema = z.object({
- title: z.string(),
+const sharedSchema = z.object({
pubDate: z
.union([z.string(), z.number(), z.date()])
- .transform((value) => new Date(value))
- .refine((value) => !isNaN(value.getTime())),
- description: z.string().optional(),
+ .optional()
+ .transform((value) => (value === undefined ? value : new Date(value)))
+ .refine((value) => (value === undefined ? value : !isNaN(value.getTime()))),
customData: z.string().optional(),
categories: z.array(z.string()).optional(),
author: z.string().optional(),
@@ -19,4 +18,21 @@ export const rssSchema = z.object({
type: z.string(),
})
.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),
+]);