mirror of
https://github.com/Sped0n/bridget.git
synced 2026-04-21 21:49:31 -07:00
refactor(resources.ts): update ImageJSON interface to include separate properties for low resolution and high resolution image URLs, heights, and widths for better organization and clarity
refactor(imageJSON.html): modify image resizing logic to generate separate low resolution and high resolution image URLs, heights, and widths to improve performance and optimize image loading
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
// data structure for images info
|
// data structure for images info
|
||||||
export interface ImageJSON {
|
export interface ImageJSON {
|
||||||
index: number
|
index: number
|
||||||
url: string
|
loUrl: string
|
||||||
imgH: number
|
loImgH: number
|
||||||
imgW: number
|
loImgW: number
|
||||||
pColor: string
|
hiUrl: string
|
||||||
sColor: string
|
hiImgH: number
|
||||||
|
hiImgW: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initResources(): ImageJSON[] {
|
export function initResources(): ImageJSON[] {
|
||||||
|
|||||||
@@ -6,12 +6,17 @@
|
|||||||
{{ $Page.Scratch.Add "img" slice }}
|
{{ $Page.Scratch.Add "img" slice }}
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
{{ $index = sub $index 1 }}
|
{{ $index = sub $index 1 }}
|
||||||
{{ $resize := .Resize "x2000 webp Lanczos q70" }}
|
{{ $lores := .Resize "1000x webp Lanczos q70" }}
|
||||||
|
{{ $hires := .Resize "2500x webp Lanczos q75" }}
|
||||||
{{ $Page.Scratch.Add "img" (dict
|
{{ $Page.Scratch.Add "img" (dict
|
||||||
"index" (int $index)
|
"index" (int $index)
|
||||||
"url" (string .RelPermalink)
|
"loUrl" (string $lores.RelPermalink)
|
||||||
"imgH" (int .Height)
|
"loImgH" (int $lores.Height)
|
||||||
"imgW" (int .Width))
|
"loImgW" (int $lores.Width)
|
||||||
|
"hiUrl" (string $hires.RelPermalink)
|
||||||
|
"hiImgH" (int $hires.Height)
|
||||||
|
"hiImgW" (int $hires.Width)
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<script id="imagesSource" type="application/json">{{ $Page.Scratch.Get "img" | jsonify | safeJS }}</script>
|
<script id="imagesSource" type="application/json">{{ $Page.Scratch.Get "img" | jsonify | safeJS }}</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user