lumeland / lume.land

The website of lume.land
https://lume.land
MIT License
68 stars 65 forks source link

add option to use local decap_cm.js instead of CDN #113

Closed hpfast closed 4 months ago

hpfast commented 4 months ago

Hi, The wait time for unpkg.com, for decap_cms.js, can be long (a minute or more). This is annoying especially in local/dev mode, but it also sometimes affects my production deployment.

Would it be possible to make this configurable, so that the user can specify a local copy of the script if they want?

I'm having a hard time deciding how to do this, though. First I tried doing it just for my site by writing a processor that modifies the rendered /admin/ page, and rewrites the src of the script to a local url. This could be encaspulated in a plugin wrapping (or coming after) the DecapCMS plugin, and it could have the desired url as an option. But this seems like a non-starter because it seems like deno-dom doesn't know about document.scripts?

So the next thing I thought of was to make the DecapCMS plugin configurable: add an option localscript or some such which the page builder function checks here: https://github.com/lumeland/lume/blob/d5ac50063d60979124ef732121a7426fc9fb436e/plugins/decap_cms.ts#L88 and uses if defined, falling back to unpkg.

It feels a bit weird to me to make this an option, but I don't see how else to make something like this configurable since the url is hard-coded.

Would you:

a. be open to a pull request adding this option b. have a suggestion for how else I could modify this?

hpfast commented 4 months ago

sorry, wrong repo!