treat foo/index.json.js as foo.json.js - fixes #297

This commit is contained in:
Rich Harris
2018-06-28 13:20:41 -04:00
parent 5b5f33d3cf
commit b7bb4db8c1
3 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
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',
'Cache-Control': `max-age=${30 * 60 * 1e3}` // cache for 30 minutes
});
res.end(contents);
}