Add auto updating last modified code to blog posts
This commit is contained in:
parent
9c6d49e14f
commit
92992c6142
6 changed files with 36 additions and 3 deletions
9
remark-modified-time.mjs
Normal file
9
remark-modified-time.mjs
Normal 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();
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue