Created
July 27, 2022 15:54
-
-
Save makotot/62a4e0d977468dd1c43c191934849b25 to your computer and use it in GitHub Desktop.
zennのコンテンツのrepoで記事のfrontmatterなどの情報を取得するjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { globby } from "globby"; | |
import matter from "gray-matter"; | |
import fs from "node:fs"; | |
const articles = await globby(["./articles/*.md"]); | |
const articleStats = articles.map((article) => { | |
const content = fs.readFileSync(article, { encoding: "utf-8" }); | |
return { | |
matter: matter(content).data, | |
mtime: fs.statSync(article).mtime, | |
}; | |
}); | |
console.log(JSON.stringify(articleStats)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment