mirror of
https://github.com/kevin-DL/sapper-template.git
synced 2026-01-22 06:15:18 +00:00
update sapper, tidy up
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules
|
node_modules
|
||||||
.sapper
|
.sapper
|
||||||
templates/.*
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -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 };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user