Skip to content
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

General usage for Static content in NextJS #157

Open
Joey-Robinson opened this issue May 14, 2020 · 3 comments
Open

General usage for Static content in NextJS #157

Joey-Robinson opened this issue May 14, 2020 · 3 comments

Comments

@Joey-Robinson
Copy link

Hey team. So I've been wanting to use this library for a project I'm working on, but I've run into an issue. When I try to use this, I'm just unable to get it to work and I was reaching out here to see if someone could assist.

https://github.com/Joey-Robinson/quick-anime-next

The above repo has a static portion I want to use and inside of components/newsletter/newsletter.coverimage.js is where I wanted to use next-optimized-images. I followed the readme pretty closely but I wasn't able to get anything to render and wanted to ask why. I feel I setup my next.config.js correctly and was using the provided tag properly, but I was getting an error cannot find assets/blog/*.jpg when trying to use it.

Any help would be greatly appreciated as I feel I'm overlooking some basic but key information.

@avantbaker
Copy link

So i think that your issue is actually coming from the fact that this plugin still looks for static as the path for images. You are using nextJS 9 which has switched to public as opposed to static. Im trying to use this package as well and that's the road block i believe that im running into @Joey-Robinson

@cyrilwanner
Copy link
Owner

It shouldn't matter where your images are located. When using them, you need to specify relative paths to them, so they should start with a ./ just like when you are importing other components/js files.
So instead of require('assets/image.jpg'), use require('./path-to-assets-folder/image.jpg') (same works with import statements).

If I've misunderstood your problem and that doesn't solve it, please provide the problematic code snippets if possible so it is easier to understand the actual problem.

@Joey-Robinson
Copy link
Author

Just to make sure we're on the same page, using This repo, I'd do something like require('./assets-path/image.jpg`) but I'd have to do that for each image? Or could I just target that folder and import the image for each file association

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants