We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3d84426 commit d8aa9b5Copy full SHA for d8aa9b5
api/posts.js
@@ -5,14 +5,13 @@ export default async function (req, res) {
5
const posts = await postLoader.getMappedByName()
6
const postName = req.url.replace('/', '')
7
if (!postName) {
8
- const allPosts = []
9
- for (const post of Object.values(posts)) {
10
- allPosts.push(post)
11
- }
+ const allPosts = Object
+ .values(posts)
+ .map(post => ({ ...post, contents: undefined }))
12
return res.writeHead(200, { 'Content-Type': 'application/json' })
13
.end(JSON.stringify(sortBy(prop('createdAt'), allPosts)))
14
}
15
-
+
16
const post = posts[postName]
17
if (!post) {
18
return res.writeHead(404).end()
0 commit comments