-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
feat: Using Next.js Image component in markdown files #6454
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Lighthouse Results
|
It breaks markdown formatted images, I will add a wrapper component that will support the markup formatted images as well; Example usage on here; |
Like we have with our Link component? You can do it like, use Next Image component if width/height provided otherwise use HTML img component. Or IDK |
Yes, I have updated the PR 🎉 Can I get a re-review for this PR? cc @nodejs/nodejs-website |
// We disable image optimisation during static export builds | ||
unoptimized: ENABLE_STATIC_EXPORT, | ||
// We allow SVGs to be used as images | ||
dangerouslyAllowSVG: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@canerakdas @ovflowd Why is dangerouslyAllowSVG
enabled?
Was something not working when it was disabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@styfle For example, we were getting error when we were not able to load the following image on the https://nodejs.org/en/about/previous-releases page
The image we are trying to load;
https://raw.githubusercontent.com/nodejs/Release/main/schedule.svg?sanitize=true
The requested resource "https://raw.githubusercontent.com/nodejs/Release/main/schedule.svg?sanitize=true" has type "image/svg+xml" but dangerouslyAllowSVG is disabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@canerakdas Seem like you could add unoptimized=true prop for that image instead of opening the risk for all images with this config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, since this image is generated from Markdown using MDX, I can't directly add unoptimized
. prop Instead, I updated the MDXImage
component to serve images with the .svg
extension as unoptimized
Here is the PR; #7244
Thank you for the feedback!
Description
With this PR, we are starting to use the
next/image
Image
component instead of the HTML img tag in markdown files.Validation
The
img
tags added from markdown pages should work correctly.You can check whether the image uses
next/image
or not via the extra attributes it adds(decoding
,data-nimg
,style
)Ex:
/en/about
Check List
npx turbo format
to ensure the code follows the style guide.npx turbo test
to check if all tests are passing.npx turbo build
to check if the website builds without errors.