feat: add remark modified time plugin
This commit is contained in:
parent
2c90929013
commit
87a0171185
2 changed files with 13 additions and 2 deletions
10
src/plugins/remark/modified-time.mjs
Normal file
10
src/plugins/remark/modified-time.mjs
Normal 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();
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue