From 3cbbc5b6da17b874552f6199a295709cf90c8767 Mon Sep 17 00:00:00 2001 From: Sped0n Date: Mon, 30 Oct 2023 17:44:59 +0800 Subject: [PATCH] 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 --- assets/ts/resources.ts | 11 ++++++----- layouts/partials/resources/imageJSON.html | 13 +++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/assets/ts/resources.ts b/assets/ts/resources.ts index 57c87f4..74aff97 100644 --- a/assets/ts/resources.ts +++ b/assets/ts/resources.ts @@ -1,11 +1,12 @@ // data structure for images info export interface ImageJSON { index: number - url: string - imgH: number - imgW: number - pColor: string - sColor: string + loUrl: string + loImgH: number + loImgW: number + hiUrl: string + hiImgH: number + hiImgW: number } export function initResources(): ImageJSON[] { diff --git a/layouts/partials/resources/imageJSON.html b/layouts/partials/resources/imageJSON.html index fd29203..c1a92b8 100644 --- a/layouts/partials/resources/imageJSON.html +++ b/layouts/partials/resources/imageJSON.html @@ -6,12 +6,17 @@ {{ $Page.Scratch.Add "img" slice }} {{ range . }} {{ $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 "index" (int $index) - "url" (string .RelPermalink) - "imgH" (int .Height) - "imgW" (int .Width)) + "loUrl" (string $lores.RelPermalink) + "loImgH" (int $lores.Height) + "loImgW" (int $lores.Width) + "hiUrl" (string $hires.RelPermalink) + "hiImgH" (int $hires.Height) + "hiImgW" (int $hires.Width) + ) }} {{- end -}}