How to use the read function from gray-matter

Find comprehensive JavaScript gray-matter.read code examples handpicked from public code repositorys.

61
62
63
64
65
66
67
68
69
70
	.pop()
	.replace(/\.[^/.]+$/, "")
// Markdown Files Logic
if (file?.endsWith(".md")) {
	// Read the Markdown file and parse it's front matter
	const mdFile = matter.read(file)

	// Convert the Markdown file content to HTML with markdown-it
	// Allows HTML tags inside the Markdown file, use highlight.js with markdown-it and highlight inline code
	const md = require("markdown-it")({ html: true }).use(require("markdown-it-highlightjs"), {
fork icon0
star icon6
watch icon1

+ 3 other calls in file

140
141
142
143
144
145
146
147
148
149
150
151


async function getAvatar(author) {
 try {
  const authorMd = path.join(__dirname, "../../content/team", author + ".md")


  const { data } = frontmatter.read(authorMd, {
   engines: { toml: toml.parse.bind(toml) },
   delimiters: "+++",
   language: "toml",
  })
fork icon0
star icon0
watch icon0