mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-13 03:25:24 +00:00
17 lines
339 B
JavaScript
17 lines
339 B
JavaScript
import posts from './blog/_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',
|
|
'Cache-Control': `max-age=${30 * 60 * 1e3}` // cache for 30 minutes
|
|
});
|
|
|
|
res.end(contents);
|
|
} |