a
This commit is contained in:
parent
4af3988df9
commit
b4bbe2a7c6
2 changed files with 40 additions and 25 deletions
|
|
@ -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();
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue