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

View file

@ -5,8 +5,8 @@ import yaml from 'js-yaml';
import bookmarksRaw from '../data/bookmarks.yaml?raw';
import fs from 'node:fs';
import path from 'node:path';
import { execSync } from 'node:child_process';
import { getApprovedEntries, type GuestbookEntry } from '../lib/db';
import { getGitDate } from '../utils';
interface Bookmark {
date: string;
@ -24,15 +24,6 @@ interface TxtConfig {
pinned?: string[];
}
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);
}
}
const posts = await getCollection('posts');
// Group by category (default: "posts")