MCPcopy
hub / github.com/midudev/preguntas-entrevista-react / fetchPost

Function fetchPost

utils/posts.js:7–22  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5}
6
7export const fetchPost = async slug => {
8 const posts = await readIndex()
9 const currentIndex = posts.findIndex(post => post.id === slug)
10
11 if (currentIndex === -1) {
12 return null
13 }
14
15 const post = await import(`../public/content/${slug}.json`)
16 const { content, level, title } = post
17
18 const prev = currentIndex > 0 ? posts[currentIndex - 1] : null
19 const next = currentIndex < posts.length - 1 ? posts[currentIndex + 1] : null
20
21 return { content, level, title, prev, next }
22}
23
24export const listPosts = async () => {
25 const posts = await readIndex()

Callers 2

generateMetadataFunction · 0.90
PostFunction · 0.90

Calls 1

readIndexFunction · 0.85

Tested by

no test coverage detected