-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a function with context for configuring MDX #8
Comments
Pretty much #11 — I'd like to be able keep my image assets next to my MDX files. Don't have any other great ideas right now! |
@schickling I've reviewed #11 and am actually using a similar approach already that works well enough, but doesn't address the capability I'd be able to get out of this feature, and which I think would be useful to many. For instance, I could create a file structure like this:
Then, inside my post I could refer to my picture like so: ![A cat](./cat-pic.png) Whereas currently, using an approach similar to what you've set up in #11 I'd have to do the following ![A cat](./blog-post/cat-pic.png) It's a minor convenience, but would allow for some tidy file structures. I think the proposed solution is (hopefully) low lift and opens up possibilities for other uses as well. I'm not sure how you'd surface this as a more proper contentlayer feature, but I could imagine a boolean along the lines of I'd be happy to take a stab at a PR for this if you're inclined. |
This should be addressed with the |
@schickling I checked out the release notes and it's not clear to me whether this would handle the case I'm talking about. The issue is that the options (specifically the This allows you to use the mdx bundling behavior with markdown images and still have them show up in standard Markdown previews, e.g., GitHub's markdown preview. As-is, the only way to accomplish that is with a totally flat content directory which leads to some pretty gnarly results. |
I'm not seeing how the I have created #266 and found a temporary solution that might solve this issue. |
Resolved via #270. While the implementation is not as flexible as this issue requested, it does satisfy my primary objective of getting a relative |
I currently have an
mdx-bundler
wrapper function something like this:You'll see that I'm able to use details from the context to configure
esbuild
formdx-bundler
. I use thefilePath
I've passed in to set an assets bundle path. I can also set thecwd
to the folder of the file being bundled, allowing for easy linking of assets in the same folder as the MDX file (bundleMDXFile
does it automatically). These options enable some nice functionality.In
contentlayer
s config I could imagine something like this:The text was updated successfully, but these errors were encountered: