Open scarf005 opened 4 months ago
You can use remote files for that: https://lume.land/docs/core/remote-files/
would it be possible to use any remote images as remote files? (e.g via regex or preprocess plugin)
I guess you can create a processor to download remote images and convert them to pages. A very simple example (needs much more work, like caching etc).
site.process([".html"], (pages, allPages) => {
for (const page of pages) {
const externalImages = page.document.querySelectorAll("img[src^='https://']");
for (const img of externalImages) {
const response = await fetch(img.getAttribute("src"));
const content = new Uint8Array(await response.arrayBuffer());
allPages.push(Page.create({
url: //generate filename using the image url
content,
});
}
}
});
does lume support some kind of 'async queue' to queue long tasks and await promise.all them later?
You can use Promise.all
in the processor:
site.process([".html"], async (pages, allPages) => {
await Promise.all(pages.map((page) => ... ));
});
alright, ill take a look this weekends.
Enter your suggestions in details:
in lume external images have significant downsides to local images due to not being able to use image plugins.