update sapper, tidy up

This commit is contained in:
Rich Harris
2017-12-17 15:07:21 -05:00
parent 600360665d
commit 28b3db6534
4 changed files with 3 additions and 6 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,4 @@
.DS_Store .DS_Store
node_modules node_modules
.sapper .sapper
templates/.*
yarn.lock yarn.lock

View File

@@ -15,7 +15,7 @@
"glob": "^7.1.2", "glob": "^7.1.2",
"marked": "^0.3.7", "marked": "^0.3.7",
"node-fetch": "^1.7.3", "node-fetch": "^1.7.3",
"sapper": "^0.0.22", "sapper": "^0.1.0",
"serve-static": "^1.13.1", "serve-static": "^1.13.1",
"style-loader": "^0.19.0", "style-loader": "^0.19.0",
"svelte": "^1.49.1", "svelte": "^1.49.1",

View File

@@ -60,7 +60,6 @@
const { slug } = params; const { slug } = params;
return fetch(`/api/blog/${slug}`).then(r => r.json()).then(post => { return fetch(`/api/blog/${slug}`).then(r => r.json()).then(post => {
console.log({ post });
return { post }; return { post };
}); });
} }

View File

@@ -6,6 +6,7 @@ const static = require('serve-static');
const { PORT = 3000 } = process.env; const { PORT = 3000 } = process.env;
// this allows us to do e.g. `fetch('/api/blog')` on the server
const fetch = require('node-fetch'); const fetch = require('node-fetch');
global.fetch = (url, opts) => { global.fetch = (url, opts) => {
if (url[0] === '/') url = `http://localhost:${PORT}${url}`; if (url[0] === '/') url = `http://localhost:${PORT}${url}`;
@@ -16,9 +17,7 @@ app.use(compression({ threshold: 0 }));
app.use(static('assets')); app.use(static('assets'));
app.use(sapper({ app.use(sapper());
selector: '#sapper'
}));
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`listening on port ${PORT}`); console.log(`listening on port ${PORT}`);