From 675338a7bbd554dfce9a1b8294937f4b2b47f7a8 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Sat, 6 Jul 2024 21:57:01 +0530 Subject: [PATCH] Add git commit hash with link to footer component --- package.json | 2 +- src/components/Footer.astro | 7 ++++++- src/env.d.ts | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a1ef2e6..0b3df27 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "prepare": "npmluau", "dev": "astro dev", "start": "astro dev", - "build": "astro build && pagefind --site dist", + "build": "COMMIT_HASH=`git rev-parse --short HEAD` astro build && pagefind --site dist", "preview": "astro preview", "astro": "astro", "new-post": "lune run new-post", diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 98af7b8..895bd0a 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,12 +1,17 @@ --- import { profileConfig } from "../config"; + +const COMMIT_HASH = import.meta.env.COMMIT_HASH; +const COMMIT_HASH_URL = COMMIT_HASH + ? `https://github.com/CompeyDev/blog.devcomp.xyz/commit/${COMMIT_HASH}` + : null; ---
© 2024 {profileConfig.name}. All Rights Reserved.
- Powered by Fuwari + Powered by Fuwari - {COMMIT_HASH ?? "dev"}
diff --git a/src/env.d.ts b/src/env.d.ts index 9c03f0a..0909ebe 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1,2 +1,10 @@ /// /// + +interface ImportMetaEnv { + readonly COMMIT_HASH?: string; +} + +interface ImportMeta { + readonly env: ImportMetaEnv; +}