feat: moves getGitDate to a shared utils file

This commit is contained in:
Lewis Wynne 2026-01-23 21:10:08 +00:00
parent 9137556a4a
commit 223bdf525a
4 changed files with 16 additions and 23 deletions

10
apps/blog/src/utils.ts Normal file
View file

@ -0,0 +1,10 @@
import { execSync } from 'node:child_process';
export function getGitDate(filePath: string): Date {
try {
const timestamp = execSync(`git log -1 --format=%cI -- "${filePath}"`, { encoding: 'utf8' }).trim();
return timestamp ? new Date(timestamp) : new Date(0);
} catch {
return new Date(0);
}
}