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}`; +}); +--- + +