blob: f51750ff51c1fcf58365b5205ac5b969b4dafb3e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import { z } from 'zod';
import type { SitemapOptions } from './index.js';
import { SitemapOptionsSchema } from './schema.js';
// @internal
export const validateOptions = (site: string | undefined, opts: SitemapOptions) => {
const result = SitemapOptionsSchema.parse(opts);
z.object({
site: z.string().optional(), // Astro takes care of `site`: how to validate, transform and refine
canonicalURL: z.string().optional(), // `canonicalURL` is already validated in prev step
})
.refine((options) => options.site || options.canonicalURL, {
message: 'Required `site` astro.config option or `canonicalURL` integration option',
})
.parse({
site,
canonicalURL: result.canonicalURL,
});
return result;
};
|