Remove artifacts and set language of markdown sites
This commit is contained in:
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.md linguist-language=Astro
|
||||||
|
*.mdx linguist-language=Astro
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user