I'm creating a blog with Next.js.
https://dev.to/imranib/build-a-next-js-markdown-blog-5777 or https://dev.to/tinacms/creating-a-markdown-blog-with-next-js-52hk talk about how to have a content / blogs folder to keep the markdown files.
I'd ideally like to keep the assets for each post in it's own folder.
According to the Next.js docs,
Next.js can serve static files, like images, under a folder called public in the root directory. Files inside public can then be referenced by your code starting from the base URL (/).
But, I don't want to have the markdown file in one place, and the images for it in another place. I'd like to have a folder structure like this:
- pages
- [blog].js
- content
- posts
- my_first_post
- index.mdx
- assets
- banner.jpeg
- another_image.png
- my_second_post
- index.mdx
- assets
- banner.jpeg
Within each .mdx file, it'd still refer to the images by its relative path to the .mdx file.
Is there an easy way to do this? I'm thinking that I'd need to, during build, copy all assets from content to public to make this work.
Update 1: I'm using I'm using next-mdx-remote and it doesn't allow imports within the mdx file.