From 45b7d42d385e247ac7a4704128ae37d9d13f9ecd Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 14:19:48 +0800 Subject: [PATCH 1/2] Add lazy loading to all images --- src/components/status.jsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/status.jsx b/src/components/status.jsx index d3424fda..03f0e76a 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -81,6 +81,7 @@ function Media({ media, showOriginal, onClick }) { alt={description} width={width} height={height} + loading="lazy" style={ !showOriginal && { backgroundColor: @@ -163,6 +164,7 @@ function Media({ media, showOriginal, onClick }) { alt={description} width={width} height={height} + loading="lazy" /> )} @@ -215,6 +217,7 @@ function Card({ card }) { src={image} width={width} height={height} + loading="lazy" alt="" onError={() => { this.style.display = 'none'; @@ -245,6 +248,7 @@ function Card({ card }) { width={width} height={height} alt={title || description} + loading="lazy" style={{ height: 'auto', aspectRatio: `${width}/${height}`, From 56cab34a9c9599b344b9196809266542a9d08207 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Thu, 15 Dec 2022 14:42:34 +0800 Subject: [PATCH 2/2] Test add last build time and commit hash --- src/pages/settings.jsx | 18 ++++++++++++++++++ vite.config.js | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/src/pages/settings.jsx b/src/pages/settings.jsx index 3205b842..0875c474 100644 --- a/src/pages/settings.jsx +++ b/src/pages/settings.jsx @@ -186,6 +186,24 @@ export default ({ onClose }) => { .

+ {__BUILD_TIME__ && ( +

+ Last build:{' '} + {' '} + {__COMMIT_HASH__ && ( + <> + ( + + {__COMMIT_HASH__} + + ) + + )} +

+ )} ); }; diff --git a/vite.config.js b/vite.config.js index f4b5207e..ac587b1c 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,9 +1,16 @@ import preact from '@preact/preset-vite'; +import { execSync } from 'child_process'; import { resolve } from 'path'; import { defineConfig, splitVendorChunkPlugin } from 'vite'; +const commitHash = execSync('git rev-parse --short HEAD').toString().trim(); + // https://vitejs.dev/config/ export default defineConfig({ + define: { + __BUILD_TIME__: JSON.stringify(Date.now()), + __COMMIT_HASH__: JSON.stringify(commitHash), + }, plugins: [preact(), splitVendorChunkPlugin()], build: { sourcemap: true,