File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ export function Footer() {
2929 } )
3030 : 'Build date not available'
3131
32+ const commitHash = import . meta. env . VITE_COMMIT_HASH
33+
3234 return (
3335 < footer className = "footer sm:footer-horizontal bg-base-200 text-base-content px-4 pt-3 pb-4 sm:p-4 relative gap-y-5" >
3436 { /* Action buttons — always pinned top-right so they never consume a row */ }
@@ -66,7 +68,23 @@ export function Footer() {
6668 className = "h-6 sm:h-7 w-auto object-contain opacity-80 hover:opacity-100 transition-opacity"
6769 />
6870 </ a >
69- < div className = "text-[10px] opacity-60" > { buildDate } </ div >
71+ < div className = "text-[10px] opacity-60 flex items-center gap-1.5" >
72+ < span > { buildDate } </ span >
73+ { commitHash && commitHash !== 'unknown' && (
74+ < >
75+ < span aria-hidden = "true" > ·</ span >
76+ < a
77+ href = { `https://github.com/Blockchain-Technology-Lab/edi-frontend/commit/${ commitHash } ` }
78+ target = "_blank"
79+ rel = "noopener noreferrer"
80+ className = "font-mono hover:opacity-100 hover:underline"
81+ title = "View this commit on GitHub"
82+ >
83+ { commitHash }
84+ </ a >
85+ </ >
86+ ) }
87+ </ div >
7088 </ aside >
7189
7290 { /*
Original file line number Diff line number Diff line change @@ -3,12 +3,23 @@ import react from '@vitejs/plugin-react'
33import mdx from '@mdx-js/rollup'
44import tailwindcss from '@tailwindcss/vite'
55import path from 'path'
6+ import { execSync } from 'child_process'
67
78const base = ''
89
910// For testing purpose, we can use a specific date as: "2024-01-15T10:30:00.000Z"
1011const buildDate = new Date ( ) . toISOString ( )
1112
13+ function getCommitHash ( ) {
14+ try {
15+ return execSync ( 'git rev-parse --short HEAD' ) . toString ( ) . trim ( )
16+ } catch {
17+ return 'unknown'
18+ }
19+ }
20+
21+ const commitHash = getCommitHash ( )
22+
1223// https://vite.dev/config/
1324export default defineConfig ( {
1425 plugins : [ mdx ( ) , react ( ) , tailwindcss ( ) ] ,
@@ -18,8 +29,9 @@ export default defineConfig({
1829 }
1930 } ,
2031 define : {
21- // Inject build date at build time
22- 'import.meta.env.VITE_BUILD_DATE' : JSON . stringify ( buildDate )
32+ // Inject build date and commit hash at build time
33+ 'import.meta.env.VITE_BUILD_DATE' : JSON . stringify ( buildDate ) ,
34+ 'import.meta.env.VITE_COMMIT_HASH' : JSON . stringify ( commitHash )
2335 } ,
2436 base : base ,
2537 build : {
You can’t perform that action at this time.
0 commit comments