fix: settings requiring service to be set when settings domains or remotePatterns (#8266)

This commit is contained in:
Erika 2023-08-29 17:54:24 +02:00 committed by GitHub
parent a78175c1b8
commit 8450379db8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix `image.service` requiring to be set manually when `image.domains` or `image.remotePatterns` was assigned a value

View file

@ -29,6 +29,9 @@ const ASTRO_CONFIG_DEFAULTS = {
split: false, split: false,
excludeMiddleware: false, excludeMiddleware: false,
}, },
image: {
service: { entrypoint: 'astro/assets/services/sharp', config: {} },
},
compressHTML: true, compressHTML: true,
server: { server: {
host: false, host: false,
@ -180,14 +183,18 @@ export const AstroConfigSchema = z.object({
.default(ASTRO_CONFIG_DEFAULTS.redirects), .default(ASTRO_CONFIG_DEFAULTS.redirects),
image: z image: z
.object({ .object({
service: z.object({ service: z
entrypoint: z.union([ .object({
z.literal('astro/assets/services/sharp'), entrypoint: z
z.literal('astro/assets/services/squoosh'), .union([
z.string(), z.literal('astro/assets/services/sharp'),
]), z.literal('astro/assets/services/squoosh'),
config: z.record(z.any()).default({}), z.string(),
}), ])
.default(ASTRO_CONFIG_DEFAULTS.image.service.entrypoint),
config: z.record(z.any()).default({}),
})
.default(ASTRO_CONFIG_DEFAULTS.image.service),
domains: z.array(z.string()).default([]), domains: z.array(z.string()).default([]),
remotePatterns: z remotePatterns: z
.array( .array(
@ -213,9 +220,7 @@ export const AstroConfigSchema = z.object({
) )
.default([]), .default([]),
}) })
.default({ .default(ASTRO_CONFIG_DEFAULTS.image),
service: { entrypoint: 'astro/assets/services/sharp', config: {} },
}),
markdown: z markdown: z
.object({ .object({
drafts: z.boolean().default(false), drafts: z.boolean().default(false),