diff --git a/packages/integrations/sitemap/src/generate-sitemap.ts b/packages/integrations/sitemap/src/generate-sitemap.ts index 0a5318c31d..653d2d5a5c 100644 --- a/packages/integrations/sitemap/src/generate-sitemap.ts +++ b/packages/integrations/sitemap/src/generate-sitemap.ts @@ -1,4 +1,4 @@ -import type { SitemapOptions, SitemapItem } from './index'; +import type { SitemapItem, SitemapOptions } from './index'; import { parseUrl } from './utils/parse-url'; const STATUS_CODE_PAGE_REGEXP = /\/[0-9]{3}\/?$/; diff --git a/packages/integrations/sitemap/src/index.ts b/packages/integrations/sitemap/src/index.ts index d0888d302a..0f1a8d7306 100644 --- a/packages/integrations/sitemap/src/index.ts +++ b/packages/integrations/sitemap/src/index.ts @@ -1,5 +1,10 @@ import type { AstroConfig, AstroIntegration } from 'astro'; -import { LinkItem as LinkItemBase, simpleSitemapAndIndex, SitemapItemLoose, EnumChangefreq } from 'sitemap'; +import { + EnumChangefreq, + LinkItem as LinkItemBase, + simpleSitemapAndIndex, + SitemapItemLoose, +} from 'sitemap'; import { fileURLToPath } from 'url'; import { ZodError } from 'zod'; diff --git a/packages/integrations/sitemap/src/schema.ts b/packages/integrations/sitemap/src/schema.ts index 3175a2e28e..9f8ab77954 100644 --- a/packages/integrations/sitemap/src/schema.ts +++ b/packages/integrations/sitemap/src/schema.ts @@ -1,39 +1,39 @@ -import { z } from 'zod'; import { EnumChangefreq as ChangeFreq } from 'sitemap'; +import { z } from 'zod'; import { SITEMAP_CONFIG_DEFAULTS } from './config-defaults'; const localeKeySchema = z.string().min(1); export const SitemapOptionsSchema = z - .object({ - filter: z.function().args(z.string()).returns(z.boolean()).optional(), - customPages: z.string().url().array().optional(), - canonicalURL: z.string().url().optional(), + .object({ + filter: z.function().args(z.string()).returns(z.boolean()).optional(), + customPages: z.string().url().array().optional(), + canonicalURL: z.string().url().optional(), - i18n: z - .object({ - defaultLocale: localeKeySchema, - locales: z.record( - localeKeySchema, - z - .string() - .min(2) - .regex(/^[a-zA-Z\-]+$/gm, { - message: 'Only English alphabet symbols and hyphen allowed', - }), - ), - }) - .refine((val) => !val || val.locales[val.defaultLocale], { - message: '`defaultLocale` must exist in `locales` keys', - }) - .optional(), + i18n: z + .object({ + defaultLocale: localeKeySchema, + locales: z.record( + localeKeySchema, + z + .string() + .min(2) + .regex(/^[a-zA-Z\-]+$/gm, { + message: 'Only English alphabet symbols and hyphen allowed', + }) + ), + }) + .refine((val) => !val || val.locales[val.defaultLocale], { + message: '`defaultLocale` must exist in `locales` keys', + }) + .optional(), - entryLimit: z.number().nonnegative().optional().default(SITEMAP_CONFIG_DEFAULTS.entryLimit), - serialize: z.function().args(z.any()).returns(z.any()).optional(), + entryLimit: z.number().nonnegative().optional().default(SITEMAP_CONFIG_DEFAULTS.entryLimit), + serialize: z.function().args(z.any()).returns(z.any()).optional(), - changefreq: z.nativeEnum(ChangeFreq).optional(), - lastmod: z.date().optional(), - priority: z.number().min(0).max(1).optional(), - }) - .strict() - .default(SITEMAP_CONFIG_DEFAULTS); + changefreq: z.nativeEnum(ChangeFreq).optional(), + lastmod: z.date().optional(), + priority: z.number().min(0).max(1).optional(), + }) + .strict() + .default(SITEMAP_CONFIG_DEFAULTS);