From d76f371c728c7019ab267c433572fe8d86f325aa Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Thu, 16 Apr 2026 21:10:25 +0300 Subject: [PATCH] hash test --- package.json | 4 +-- src/components/BuildHashBlocks.astro | 42 ++++++++++++++++++++++++++++ src/components/Footer.astro | 5 +++- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 src/components/BuildHashBlocks.astro diff --git a/package.json b/package.json index 8ef3aa5..3d509c8 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,10 @@ "node": ">=22.12.0" }, "scripts": { - "dev": "astro dev", + "dev": "PUBLIC_GIT_COMMIT=$(git rev-parse HEAD) astro dev", "preview": "astro preview", "astro": "astro", - "build": "astro build" + "build": "PUBLIC_GIT_COMMIT=$(git rev-parse HEAD) astro build" }, "dependencies": { "@astrojs/rss": "^4.0.17", diff --git a/src/components/BuildHashBlocks.astro b/src/components/BuildHashBlocks.astro new file mode 100644 index 0000000..c6f703d --- /dev/null +++ b/src/components/BuildHashBlocks.astro @@ -0,0 +1,42 @@ +--- +const rawHash = (import.meta.env.PUBLIC_GIT_COMMIT || "") + .replace(/[^a-fA-F0-9]/g, "") + .toLowerCase(); + +const safeHash = rawHash || "0000000000000000000000000000000000000000"; + +const blockCount = 6; +const hexPerBlock = 6; + +const blocks: string[] = Array.from({ length: blockCount }, (_, i) => { + const start = i * hexPerBlock; + const part = safeHash.slice(start, start + hexPerBlock).padEnd(6, "0"); + return `#${part}`; +}); +--- + +
+ { + blocks.map((color: string) => ( + + )) + } +
+ + diff --git a/src/components/Footer.astro b/src/components/Footer.astro index e0ca0c3..0836412 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,6 +1,7 @@ --- import { getLangFromUrl, getTranslations, type Lang } from "@/i18n"; - +import BuildHashBlocks from "@/components/BuildHashBlocks.astro"; +const commit = import.meta.env.PUBLIC_GIT_COMMIT || "unknown"; const lang = getLangFromUrl(Astro.url); const t = getTranslations(lang); --- @@ -8,6 +9,8 @@ const t = getTranslations(lang);