feat: add remark modified time plugin

This commit is contained in:
草师傅 2025-08-10 18:20:51 +08:00
parent 2c90929013
commit 87a0171185
Signed by: gb
GPG key ID: 43330A030E2D6478
2 changed files with 13 additions and 2 deletions

View file

@ -0,0 +1,10 @@
import { execSync } from "child_process";
import { statSync } from "node:fs";
export function remarkModifiedTime() {
return function (tree, file) {
const filepath = file.history[0];
const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`).toString() || statSync(filepath).mtime.toISOString();
file.data.astro.frontmatter.lastModified = result.toString();
};
}