-
Notifications
You must be signed in to change notification settings - Fork 1
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
Any way to add images from the same folder as posts? #1
Comments
Hey @deadcoder0904, that's a good question, I want to try to do something like that. I have this idea that probably we can import the images the same way they do in that tailwind post and use Then add that The idea would be to have it like this in the mdx file: import image1 from './image1.jpg'
import image2 from './image2.jpg'
---
title: '#100DaysOfGatsby'
date: 2020-01-04T10:00:17-0600
tags:
- gatsbyjs
---
Some content here.
<Img src={image1} sizes={[500]} />
<Img src={image2} sizes={[500]} /> Thats the main idea haha need to test if it works that way. |
I just found remark-embed-images, seems like this would work too adding is as a remark plugin here. I'm gonna see if it's possible to combine with Img component to optimize images while embedding them. |
@osiux Your 1st comment is what I thought would work too but it doesn't work like that. I made a minimal repo to see if it works & it doesn't → https://github.com/deadcoder0904/blog-mdx-remote Check the code here where I used MDX Provider → https://github.com/deadcoder0904/blog-mdx-remote/blob/master/pages/_app.js#L7-L13 I also tried doing the way you mentioned in the 1st comment using And the author of Although do let me know if your 2nd comment is working as expected because I'd love to use |
@deadcoder0904 Makes sense, then I think my idea to use the remark plugin with another component might not work. For now I think the solution would be to use that plugin as is, but it would not optimize images, that needs to be done manually. What the plugin does is read the file from the markdown, like this:
Reads the content and embeds the base64 string. I think thit is the closest you are gonna get to have the images in the same folder, but i'll try my theory tomorrow haha |
@osiux cool, I'll wait till 2mrrw then otherwise move on to some other solution as the Tailwind guys did :)
when you say this, it's not really possible for big images like 1 MB or more....as that would result in HTML content too big, right? |
@deadcoder0904 Hi, have you managed to import images from the same folder using next-mdx-remote? Currently I'm following what tailwindcss blog did here and it works. I want to switch to |
Hey @dpyzo0o, I tried Tailwind's approach → https://github.com/deadcoder0904/blog-mdx-next/tree/tailwind but got stuck because my blog is a little different. I want it to have Then I just tried Egghead's approach which is using Lmk if you have any ideas? |
@deadcoder0904 I think you might try webpack's include/exclude conditions to apply rules to certain folders. See here for more details. |
Holy shit it actually worked. Thank you so much 🙌 Here's the commit → deadcoder0904/blog-mdx-next@84ad004 |
I just stumbled upon your repo while searching Github.
There are not many repo's using images & I want to make a blog with
next-mdx-remote
with images in the same folder as posts.So my question is, is there any way to have images in the same folder as posts & reference it from there because I like co-location like the Tailwind Blog?
The text was updated successfully, but these errors were encountered: