mirror of
https://github.com/withastro/astro.git
synced 2024-12-30 22:03:56 -05:00
b8c6dabfb7
* enabling eslint on the all packages and tests * enabling for all packages * TEMP: adding an only() test to verify it fails CI * using our eslint config and ignore in CI * removing the temporary .only() test * update lock file * lint: fixing new test with a no-shadow warning * chore: update lock file
22 lines
724 B
TypeScript
22 lines
724 B
TypeScript
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;
|
|
};
|