mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-23 15:01:27 +00:00
initial commit
This commit is contained in:
16
routes/blog/index.json.js
Normal file
16
routes/blog/index.json.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import posts from './_posts.js';
|
||||
|
||||
const contents = JSON.stringify(posts.map(post => {
|
||||
return {
|
||||
title: post.title,
|
||||
slug: post.slug
|
||||
};
|
||||
}));
|
||||
|
||||
export function get(req, res) {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'application/json'
|
||||
});
|
||||
|
||||
res.end(contents);
|
||||
}
|
||||
Reference in New Issue
Block a user