-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Pass remote Markdown images through image service #13254
feat: Pass remote Markdown images through image service #13254
Conversation
When in regular .md files, the images show up as expected. However, in content md files, they still misbehave. Also, it seems the responsive attributes are only added by the <Image> component, not the image transformation that's done later, which I find a bit weird; there's other responsive stuff being done tho?? So maybe I need to fix that while I'm here too.
🦋 Changeset detectedLatest commit: a21e0b5 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
CodSpeed Performance ReportMerging #13254 will not alter performanceComparing Summary
|
This time the fail was becase we were transforming too many remote images. We should inject allowedRemoteDomains into the remark plugin so we only collect the allowed remote images in the first place.
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.
Thank you @p0lyw0lf for your PR! I left some comments and questions around the new feature
This commit moves remote pattern checking functionality into @astrojs/markdown-remark, out of the main astro package, so it can be used by remark-collect-images. We do this instead of moving it into a shared @astrojs/internal-helpers because part of that package uses node APIs, and remark-collect-images needs to work in a browser.
@ematipico I believe I've addressed your feedback. One of the bigger changes was moving the checks for https://docs.astro.build/en/guides/images/#authorizing-remote-images out of |
This time, the problem is certain parts of `astro` don't like depending on `@astrojs/markdown-remark`, because it brings in `node:fs` somehow. This on its own is probably a problem, but I think I'll work around it by moving the relevant shared code into `@astrojs/internal-helpers/remote` so that we can stay node-free.
The fixes I pushed this morning were not enough; there was a error where moving |
Since you added code to another package, that package must have a changeset. Without changeset it won't have its version bumped and it will break in production. It should be a new changeset, not the one you currently have |
@ematipico I've updated the changeset |
@p0lyw0lf Thank you for you PR. Coding-wise, it looks good to me. Would you be able to send a PR to docs? If not, that's fine, we can do that. Just let us know. We aim to release the new feature next Thursday. |
@ematipico I opened a docs PR: withastro/docs#11021 Also, any notes on #13256 by any chance? |
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.
Exciting feature! 🚀
I left my thought on the changeset for docs, and Ema can guide you on creating individual ones that describe what's new / changes about the other packages.
I've also reviewed the docs PR which won't take much to polish it up! 🙌
(Also noting, I didn't notice any new error messages associated with this feature.)
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
@sarah11918 @ematipico I've split the changeset into multiple, adding specifics on what's changed for each package. Thanks again for reviewing this!! |
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
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.
Looks good to me! Approving for docs! 🥳
(And noting that I dont see any new error messages introduced with this feature)
Has anything changed on the usage side? having
would still work? |
Changes
Testing
I tested this change by creating a small project with a single allowed remote domain, and rendering markdown files from:
Both approaches work. I can provide these test files if needed, though I'm not sure how we'll want to deal with the fact it'll require an internet connection.
Known Issues
If the remote image is styled in some way, the newly added
width
andheight
attributes could mess up that styling. Ideally, we'd like to be able to modify the properties aftergetImage
runs somehow, but seeing as this is also the case for local images transformed using this method too, I think this is more a deficiency ingetImage
best left addressed by the responsive image experiment.This is only an issue for remote images as configured under
images.domains
. Other images are untouched.Docs
If this change goes through, we will need to update the images guide to reflect that remote images are now supported in markdown files. PR: withastro/docs#11021