feat: display last modified and wordcount on article

This commit is contained in:
草师傅 2025-08-10 18:37:37 +08:00
parent f8d69ac954
commit 666349c5b8
Signed by: gb
GPG key ID: 43330A030E2D6478
2 changed files with 11 additions and 5 deletions

View file

@ -1,10 +1,9 @@
import { execSync } from "child_process";
import { statSync } from "node:fs";
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();
file.data.astro.frontmatter.lastModified = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`).toString() || statSync(filepath).mtime.toISOString();
};
}