Skip to content

Commit 0ee5f2a

Browse files
committed
add site info at footer
1 parent 3e063e7 commit 0ee5f2a

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

astro.config.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
// @ts-check
22
import { defineConfig } from 'astro/config';
3+
import { execSync } from 'child_process';
34

45
import sitemap from "@astrojs/sitemap";
56

7+
function getCommitHash() {
8+
// Cloudflare Pages provides this env var
9+
if (process.env.CF_PAGES_COMMIT_SHA) {
10+
return process.env.CF_PAGES_COMMIT_SHA.slice(0, 7);
11+
}
12+
// Fallback for local builds
13+
try {
14+
return execSync('git rev-parse --short HEAD').toString().trim();
15+
} catch {
16+
return 'dev';
17+
}
18+
}
19+
620
export default defineConfig({
721
site: "https://andrewpollack.dev",
822
trailingSlash: "always",
923
integrations: [sitemap()],
24+
vite: {
25+
define: {
26+
__COMMIT_HASH__: JSON.stringify(getCommitHash()),
27+
},
28+
},
1029
});

src/components/Footer.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
<a href="https://www.linkedin.com/in/andrewpkq">LinkedIn</a> |
55
<a href="https://bsky.app/profile/andrewpollack.dev">BlueSky</a>
66
</p>
7+
<p class="commit">
8+
Site version <a href={`https://github.com/andrewpollack/site/commit/${__COMMIT_HASH__}`}>{__COMMIT_HASH__}</a>, <a href="https://github.com/andrewpollack/site">source code</a>
9+
</p>
710
</footer>

src/env.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="astro/client" />
2+
3+
declare const __COMMIT_HASH__: string;

src/styles/style.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,22 @@ footer {
199199
color: var(--muted-text);
200200
}
201201

202+
footer .commit {
203+
font-size: 0.8em;
204+
opacity: 0.6;
205+
margin-top: 4px;
206+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
207+
}
208+
209+
footer .commit a {
210+
font-weight: 400;
211+
text-decoration: none;
212+
}
213+
214+
footer .commit a:hover {
215+
text-decoration: underline;
216+
}
217+
202218
/* -------------------------
203219
Typography
204220
------------------------- */

0 commit comments

Comments
 (0)