Skip to content

Commit 6be3787

Browse files
authored
Merge pull request #117 from Blockchain-Technology-Lab/ipfs
added github hash on footer
2 parents 9cbbac0 + e568526 commit 6be3787

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

src/components/layout/Footer.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff 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">&middot;</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
{/*

vite.config.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,23 @@ import react from '@vitejs/plugin-react'
33
import mdx from '@mdx-js/rollup'
44
import tailwindcss from '@tailwindcss/vite'
55
import path from 'path'
6+
import { execSync } from 'child_process'
67

78
const base = ''
89

910
// For testing purpose, we can use a specific date as: "2024-01-15T10:30:00.000Z"
1011
const 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/
1324
export 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: {

0 commit comments

Comments
 (0)