#Path to images in markdown files

7 messages · Page 1 of 1 (latest)

ripe pecan
#

Hi there,
How can you reference local assets in markdown files that are up a directory to the content.

e.g. markdown files are at src/content/episodes
images are at src/content/images/Episodes/<Episode #>/<image>.ext

in the .md files ![test](../images/Episodes/Episode1/test.jpeg) returns image not found

#

ah, it works but can not have spaces in the path

valid hatch
#

You could also do:

src/content/episodes/episode1/index.md
src/content/episodes/episode1/image.jpg

if you want to co-locate stuff in the same folder

ripe pecan
valid hatch
#

I think you might be able to do something with remark or rehype plugins, but not sure. If you're using MDX, then you can use Astro's <Image /> component and uset sizes.

ripe pecan
valid hatch
#

I think you can do something like this, as long as the file extension is hard-coded and not part of the literal string.

<Image src={import(`../${imgSource}.png`)} alt="whatever" />