Skip to content

Instantly share code, notes, and snippets.

@makotot
Created July 27, 2022 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makotot/62a4e0d977468dd1c43c191934849b25 to your computer and use it in GitHub Desktop.
Save makotot/62a4e0d977468dd1c43c191934849b25 to your computer and use it in GitHub Desktop.
zennのコンテンツのrepoで記事のfrontmatterなどの情報を取得するjs
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