Replies: 2 comments 2 replies
-
It has been a long time since I tried it and I remembered it being relatively tricky to set up. Besides modifying the image links from the markdown file using |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hey @nk9, did you ever work this out? I would want to move to nextjs from gatsby but not without this functionality |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am going to have many pages, each one of which will have 1+ images. I'd prefer to place the images next to their associated mdx files, ideally like this:
This is inspired by Hugo page bundles. I'd like this to generate two routes:
I haven't gotten this to work yet with this template. This seems to require two changes, one to expect
index.md[x]
and ignore it in favor of the directory, and the other to import images placed next to the mdx. I've started with the image piece.The mdxBundler README suggests two ways to bundle images placed next to MDX files with
remark-mdx-images
, using eitherdataurl
s, orfile
URLs. I've placed this in theintroducing-multi-…
file:![thumbnail](page.jpg)
and then tried different changes tolib/mdx.js
, including:cwd
passed tobundleMDX
todata/blog
and passing the remark plugin toxdmOptions
.This required me to update the path to various components in different mdx files, but that was easy enough. Unfortunately, the page build still fails with
error: Could not resolve "./page.jpg"
mdxOptions
key to thebundleMDX
dictionary and addingremarkMdxImages
to the options there:That got further, since the page actually builds now. But the image isn't bundled as a
dataurl
and just appears as "thumbnail" in the rendered page. In the console, I get:ENOENT: no such file or directory, open '/path/to/my-blog/data/blog/nested-route/page.jpg.md'
cwd
in these cases to be the parent directory of the mdx, e.g.cwd: path.join(root, 'data', type),
. This didn't seem to change the errors or behavior at all.I haven't actually tried the
file
URL approach, since it seems to be a bit more involved and I can't even get the simple one working.Am I on the right track here? I'd appreciate a pointer to how to set this up.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions