fix: properly generate code for multiple images in same markdown file (#8633)
This commit is contained in:
parent
de7a7fbdc3
commit
63141f3f3e
4 changed files with 11 additions and 3 deletions
5
.changeset/mean-forks-ring.md
Normal file
5
.changeset/mean-forks-ring.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix build not working when having multiple images in the same Markdown file
|
|
@ -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')}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
![My article cover](../assets/penguin1.jpg)
|
||||
![My article cover](../assets/penguin2.jpg)
|
||||
|
||||
Image worked
|
||||
|
|
Loading…
Reference in a new issue