diff options
author | 2023-03-17 13:29:25 +0100 | |
---|---|---|
committer | 2023-03-17 13:29:25 +0100 | |
commit | f5fddafc248bb1ef57b7349bfecc25539ae2b5ea (patch) | |
tree | a5e57b36cd9a3b388ff41ab05ff8c9145959b124 /packages/markdown/remark/src | |
parent | f413446a859e497395b3612e44d1540cc6b9dad7 (diff) | |
download | astro-f5fddafc248bb1ef57b7349bfecc25539ae2b5ea.tar.gz astro-f5fddafc248bb1ef57b7349bfecc25539ae2b5ea.tar.zst astro-f5fddafc248bb1ef57b7349bfecc25539ae2b5ea.zip |
Add validateOptions hook to Image Service API (#6555)
* feat(assets): Add a validateOptions hooks to set default and do error handling
* chore: changeset
Diffstat (limited to 'packages/markdown/remark/src')
-rw-r--r-- | packages/markdown/remark/src/rehype-images.ts | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/markdown/remark/src/rehype-images.ts b/packages/markdown/remark/src/rehype-images.ts index fcd39cd60..1d615c8b5 100644 --- a/packages/markdown/remark/src/rehype-images.ts +++ b/packages/markdown/remark/src/rehype-images.ts @@ -38,11 +38,15 @@ export function rehypeImages(imageService: any, assetsDir: URL | undefined, getI alt: node.properties.alt, }; - const imageURL = imageService.getURL(options); + const validatedOptions = imageService.validateOptions + ? imageService.validateOptions(options) + : options; + + const imageURL = imageService.getURL(validatedOptions); node.properties = Object.assign(node.properties, { src: imageURL, ...(imageService.getHTMLAttributes !== undefined - ? imageService.getHTMLAttributes(options) + ? imageService.getHTMLAttributes(validatedOptions) : {}), }); } |