diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..871cb8a --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.md linguist-language=Astro +*.mdx linguist-language=Astro diff --git a/src/remark-modified-time.mjs b/src/remark-modified-time.mjs deleted file mode 100644 index 1881cca..0000000 --- a/src/remark-modified-time.mjs +++ /dev/null @@ -1,22 +0,0 @@ -import { execSync } from "child_process"; -import { statSync } from "fs"; - -export function remarkModifiedTime() { - return function (tree, file) { - const filepath = file.history[0]; - try { - const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`); - // If result is empty or undefined, fallback to fs stat - if (!result || !result.toString().trim()) { - throw new Error("No git history"); - } - file.data.astro.frontmatter.lastModified = result.toString(); - return; - } catch (e) { - // Ignore, fallback to fs stat - const result = statSync(filepath); - file.data.astro.frontmatter.lastModified = result.mtime.toISOString(); - return; - } - }; -}