My landing page, written in Astro hayden.moe
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: declare git hash as a global via vite

+14 -9
+10
astro.config.mjs
··· 1 1 import { defineConfig } from 'astro/config'; 2 2 import cloudflare from '@astrojs/cloudflare'; 3 + import childProcess from "child_process"; 3 4 4 5 import tailwindcss from '@tailwindcss/vite'; 6 + 7 + // obtain Git commit hash 8 + const hash = childProcess 9 + .execSync("git rev-parse --short HEAD") 10 + .toString() 11 + .trim(); 5 12 6 13 export default defineConfig({ 7 14 site: 'https://hayden.moe', ··· 14 21 }), 15 22 vite: { 16 23 plugins: [tailwindcss()], 24 + define: { 25 + __GIT_HASH__: JSON.stringify(hash), 26 + }, 17 27 build: { 18 28 rollupOptions: { 19 29 external: ['shiki/onig.wasm'],
+2
env.d.ts
··· 1 1 /// <reference types="astro/client" /> 2 2 3 + declare var __GIT_HASH__: string; 4 + 3 5 // use a default runtime configuration (advanced mode). 4 6 type Runtime = import("@astrojs/cloudflare").Runtime<Env>; 5 7 declare namespace App {
+2 -9
src/components/footer.astro
··· 1 1 --- 2 - import childProcess from "child_process"; 3 - 4 - const today = new Date(); 5 - 6 - // obtain Git commit hash 7 - const hash = childProcess 8 - .execSync("git rev-parse --short HEAD") 9 - .toString() 10 - .trim(); 2 + const today = new Date(); 3 + const hash = __GIT_HASH__; 11 4 --- 12 5 <p class="text-base03 px-4 py-2"> 13 6 Copyright (c) Hayden Young {today.getFullYear()}. Version <a target="_blank" href={`https://github.com/hbjydev/hayden.moe/commit/${hash}`} class="decoration-wavy underline hover:text-pink transition-color duration-200">{hash}</a>.