MCPcopy Create free account
hub / github.com/StaticMania/keep-react / getBlogs

Function getBlogs

utils/getMdxContent.ts:7–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const blogsDirectory = path.join(process.cwd(), 'data/blogs')
6
7export const getBlogs = () => {
8 const fileNames = fs.readdirSync(blogsDirectory)
9
10 const blogs = fileNames.map((fileName) => {
11 const filePath = path.join(blogsDirectory, fileName)
12
13 const fileContents = fs.readFileSync(filePath, 'utf8')
14
15 const { data, content } = matter(fileContents)
16
17 return {
18 slug: fileName.replace(/\.mdx$/, ''),
19 title: data?.title,
20 tag: data?.tag,
21 date: data?.date,
22 version: data?.version,
23 author: data?.author,
24 content,
25 }
26 })
27
28 return blogs
29}

Callers 4

pageFunction · 0.90
generateStaticParamsFunction · 0.90
generateMetadataFunction · 0.90
pageFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected