This commit is contained in:
icefox 2025-12-26 13:04:49 -03:00
parent 4af3988df9
commit b4bbe2a7c6
No known key found for this signature in database
2 changed files with 40 additions and 25 deletions

View file

@ -31,15 +31,20 @@
width: 1080,
height: 1920,
imaginary: '{{.ImaginaryURL}}',
pages: [{{range $i, $p := .Pages}}{{if $i}},{{end}}{path: '{{$p.Path}}', prefix: '{{$p.Prefix}}'}{{end}}],
pages: [{{range $i, $p := .Pages}}{{if $i}},{{end}}'{{$p}}'{{end}}],
urls: [],
prefetched: new Set(),
imageExts: ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.bmp', '.avif'],
isImage(path) {
const ext = path.substring(path.lastIndexOf('.')).toLowerCase();
return this.imageExts.includes(ext);
},
buildUrls() {
this.urls = this.pages.map(p => {
if (p.prefix === 'imaginary') {
return this.imaginary + '/fit?width=' + this.width + '&height=' + this.height + '&file=' + encodeURIComponent(p.path);
if (this.isImage(p)) {
return this.imaginary + '/fit?width=' + this.width + '&height=' + this.height + '&file=' + encodeURIComponent(p);
}
return '/static/' + p.path;
return '/static/' + p;
});
this.prefetched.clear();
},