This commit is contained in:
2026-02-24 22:13:00 +01:00
parent 7576f6bcf6
commit d3d8e60a25
47 changed files with 1352 additions and 193 deletions

View File

@@ -0,0 +1,22 @@
import { execSync } from "child_process";
import { statSync } from "fs";
export function remarkModifiedTime() {
return function (tree, file) {
const filepath = file.history[0];
try {
const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`);
// If result is empty or undefined, fallback to fs stat
if (!result || !result.toString().trim()) {
throw new Error("No git history");
}
file.data.astro.frontmatter.lastModified = result.toString();
return;
} catch (e) {
// Ignore, fallback to fs stat
const result = statSync(filepath);
file.data.astro.frontmatter.lastModified = result.mtime.toISOString();
return;
}
};
}