summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.changeset/mean-forks-ring.md5
-rw-r--r--packages/astro/src/vite-plugin-markdown/index.ts6
-rw-r--r--packages/astro/test/core-image.test.js2
-rw-r--r--packages/astro/test/fixtures/core-image/src/pages/post.md1
4 files changed, 11 insertions, 3 deletions
diff --git a/.changeset/mean-forks-ring.md b/.changeset/mean-forks-ring.md
new file mode 100644
index 000000000..1aa40a6b5
--- /dev/null
+++ b/.changeset/mean-forks-ring.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Fix build not working when having multiple images in the same Markdown file
diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts
index 7d4a97392..dfc0bc0e0 100644
--- a/packages/astro/src/vite-plugin-markdown/index.ts
+++ b/packages/astro/src/vite-plugin-markdown/index.ts
@@ -120,13 +120,15 @@ export default function markdown({ settings, logger }: AstroPluginOptions): Plug
${layout ? `import Layout from ${JSON.stringify(layout)};` : ''}
import { getImage } from "astro:assets";
- ${imagePaths.map((entry) => `import Astro__${entry.safeName} from ${JSON.stringify(entry.raw)};`)}
+ ${imagePaths
+ .map((entry) => `import Astro__${entry.safeName} from ${JSON.stringify(entry.raw)};`)
+ .join('\n')}
const images = async function() {
return {
${imagePaths
.map((entry) => `"${entry.raw}": await getImage({src: Astro__${entry.safeName}})`)
- .join('\n')}
+ .join(',\n')}
}
}
diff --git a/packages/astro/test/core-image.test.js b/packages/astro/test/core-image.test.js
index 7a0a46822..a6ee4342c 100644
--- a/packages/astro/test/core-image.test.js
+++ b/packages/astro/test/core-image.test.js
@@ -310,7 +310,7 @@ describe('astro:image', () => {
it('Adds the <img> tag', () => {
let $img = $('img');
- expect($img).to.have.a.lengthOf(1);
+ expect($img).to.have.a.lengthOf(2);
// Verbose test for the full URL to make sure the image went through the full pipeline
expect(
diff --git a/packages/astro/test/fixtures/core-image/src/pages/post.md b/packages/astro/test/fixtures/core-image/src/pages/post.md
index 98da01ce4..822ed6189 100644
--- a/packages/astro/test/fixtures/core-image/src/pages/post.md
+++ b/packages/astro/test/fixtures/core-image/src/pages/post.md
@@ -1,3 +1,4 @@
![My article cover](../assets/penguin1.jpg)
+![My article cover](../assets/penguin2.jpg)
Image worked