This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Sapper export also follows <img src='...'/> and exports these #938
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is not related to any issue that I could find, I just wanted something like this and made a PR.
It might not be the cleanest way to solve this issue, or even desired, so I welcome feedback.
Current behaviour
Sapper export follows
<a href='>
links, but not<img src="catlolz.png"/>
.New behaviour
Sapper export follows
<img src='catlolz.pong'/>
links and exports the image.Changes
src
attributes;r.text()
orr.arrayBuffer()
;Why
For myself I have a static website with blog posts in the following structure:
The
index.md
file refers to the image. I could put the image in thestatic
folder and refer to it but the image belongs to this post. It seems nicer to also intercept requests for images in the export.You do need an endpoint that serves the images, but this is also an advantage because now we can optimize those images dynamically (resize, compress, etc) by giving information from the front end.
Points of attention
You probably do not want to wildly grab all image links on your website. I think there was a filter in Sapper to exclude files from outside your own website, so that should apply. I didn't test this yet.