Add auto updating last modified code to blog posts

This commit is contained in:
Aria 2025-03-10 13:31:51 +11:00
parent 9c6d49e14f
commit 92992c6142
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
6 changed files with 36 additions and 3 deletions

9
remark-modified-time.mjs Normal file
View file

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