Skip to content

Commit

Permalink
apply suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Dec 4, 2024
1 parent d7e749f commit 7c0a1b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/assets/utils/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type SvgRenderMode = 'inline' | 'sprite';
export function makeSvgComponent(
meta: ImageMetadata,
contents: Buffer | string,
options?: { mode: SvgRenderMode },
options?: { mode?: SvgRenderMode },
) {
const file = typeof contents === 'string' ? contents : contents.toString('utf-8');
const { attributes, body: children } = parseSvg(file);
Expand Down
14 changes: 11 additions & 3 deletions packages/astro/src/core/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,11 @@ export const AstroConfigSchema = z.object({
svg: z
.union([
z.boolean(),
z.object({
mode: z.union([z.literal('inline'), z.literal('sprite')]),
}),
z
.object({
mode: z.union([z.literal('inline'), z.literal('sprite')]).optional(),
})
.optional(),
])
.optional()
.default(ASTRO_CONFIG_DEFAULTS.experimental.svg)
Expand All @@ -553,6 +555,12 @@ export const AstroConfigSchema = z.object({
mode: 'inline' as SvgRenderMode,
}
: undefined;
} else {
if (!svgConfig.mode) {
return {
mode: 'inline' as SvgRenderMode,
};
}
}
return svgConfig;
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { defineConfig } from 'astro/config';
export default defineConfig({
integrations: [mdx()],
experimental: {
svg: true
svg: {}
}
});

0 comments on commit 7c0a1b4

Please sign in to comment.