-
Notifications
You must be signed in to change notification settings - Fork 51
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
img tag is not inside exported html #42
Comments
Hi @NicolasRoehm, Thanks for the bug report. I looked, and I know at least why this noscript img tag is not being generated. This is how the export is taking place. I need to use the dynamic function with SSR off as there is a hydration error otherwise. When I would export the ExportedImage component directly, the noscript img tag would be generated but the hydration error occurs. const DynamicExportedImage = dynamic(() => Promise.resolve(ExportedImage), {
ssr: false,
});
export default function (props: ExportedImageProps) {
const isStaticImage = typeof props.src === "object";
const width = (isStaticImage && props.width) || (props.src as any).width;
const height = (isStaticImage && props.height) || (props.src as any).height;
return isStaticImage ? (
<div style={isStaticImage ? { aspectRatio: width / height } : {}}>
<DynamicExportedImage {...props} />
</div>
) : (
<DynamicExportedImage {...props} />
);
} I have to find a workaround for the hydration error. I think it happs because the environment variables are not accessible on the server side inside an imported module like the ExportedImage component. |
Hi @Niels-IO, |
Hi @NicolasRoehm, I played around, but I cannot get around one issue: The ExportedImage component is a compiled commonjs file, and for the first server render, the process.env is undefined. One solution would be that I can export the ExportedImage component as an ES module and let Next.js compile the source. Unfortunately, I have had no luck in getting this to work for now. |
Using something like https://github.com/martpie/next-transpile-modules ? |
Hi @NicolasRoehm, The noscript tags should work properly now. Check out version 0.15.0 🙂 |
Hi Niels,
Thank you for the great library, it's awesome! I wonder why my statically exported HTML doesn't contain any
img
tag.It seems that javascript is required to display the image on the page, is this normal?
By default, NextJs is able to export the generated HTML :
Best regards,
The text was updated successfully, but these errors were encountered: