summaryrefslogtreecommitdiff
path: root/packages/integrations/mdx/src/rehype-images-to-component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/mdx/src/rehype-images-to-component.ts')
-rw-r--r--packages/integrations/mdx/src/rehype-images-to-component.ts5
1 files changed, 2 insertions, 3 deletions
diff --git a/packages/integrations/mdx/src/rehype-images-to-component.ts b/packages/integrations/mdx/src/rehype-images-to-component.ts
index da2f25ee5..8e8c9f3ae 100644
--- a/packages/integrations/mdx/src/rehype-images-to-component.ts
+++ b/packages/integrations/mdx/src/rehype-images-to-component.ts
@@ -73,13 +73,12 @@ function getImageComponentAttributes(props: Properties): MdxJsxAttribute[] {
export function rehypeImageToComponent() {
return function (tree: Root, file: VFile) {
- if (!file.data.astro?.imagePaths) return;
-
+ if (!file.data.astro?.imagePaths?.length) return;
const importsStatements: MdxjsEsm[] = [];
const importedImages = new Map<string, string>();
visit(tree, 'element', (node, index, parent) => {
- if (!file.data.astro?.imagePaths || node.tagName !== 'img' || !node.properties.src) return;
+ if (!file.data.astro?.imagePaths?.length || node.tagName !== 'img' || !node.properties.src) return;
const src = decodeURI(String(node.properties.src));