Skip to content

Commit ce76b9d

Browse files
Lofty-Bramblesopenscript
authored andcommitted
fix(@astrojs/netlify): Handle SVGs properly with imageCDN enabled (withastro#13830)
* fix: handle svgs separately by fetching original source path * feat: add a changeset
1 parent c026fa2 commit ce76b9d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

.changeset/loud-brooms-kick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/netlify': patch
3+
---
4+
5+
Fixes an issue with SVGs not rendering with image-cdn enabled, due to invalid source path parsing.

packages/integrations/netlify/src/image-service.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ function removeLeadingForwardSlash(path: string) {
1212

1313
const service: ExternalImageService = {
1414
getURL(options) {
15+
// For SVG files, return the original source path
16+
if (isESMImportedImage(options.src) && options.src.format === 'svg') {
17+
return options.src.src;
18+
}
19+
20+
// For non-SVG files, continue with the Netlify's image processing
1521
const query = new URLSearchParams();
1622

1723
const fileSrc = isESMImportedImage(options.src)

0 commit comments

Comments
 (0)