0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00

[ci] format

This commit is contained in:
natemoo-re 2022-06-20 19:31:39 +00:00 committed by github-actions[bot]
parent facfc4682f
commit 9532d56b50
3 changed files with 37 additions and 32 deletions

View file

@ -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}\/?$/;

View file

@ -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';

View file

@ -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);