This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 432
fix: add link rel=preload for exported sites #568
Merged
Rich-Harris
merged 3 commits into
sveltejs:master
from
nolanlawson:nolan/preload-in-export
Feb 17, 2019
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as sapper from '@sapper/app'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copy-pasta'd the |
||
|
||
window.start = () => sapper.start({ | ||
target: document.querySelector('#sapper') | ||
}); | ||
|
||
window.prefetchRoutes = () => sapper.prefetchRoutes(); | ||
window.prefetch = href => sapper.prefetch(href); | ||
window.goto = href => sapper.goto(href); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<h1>{status}</h1> | ||
|
||
<p>{error.message}</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script context="module"> | ||
export function preload({ params }) { | ||
return this.fetch(`blog/${params.slug}.json`).then(r => r.json()).then(post => { | ||
return { post }; | ||
}); | ||
} | ||
</script> | ||
|
||
<script> | ||
export let post; | ||
</script> | ||
|
||
<h1>{post.title}</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import posts from './_posts.js'; | ||
|
||
export function get(req, res) { | ||
const post = posts.find(post => post.slug === req.params.slug); | ||
|
||
if (post) { | ||
res.writeHead(200, { | ||
'Content-Type': 'application/json' | ||
}); | ||
|
||
res.end(JSON.stringify(post)); | ||
} else { | ||
res.writeHead(404, { | ||
'Content-Type': 'application/json' | ||
}); | ||
|
||
res.end(JSON.stringify({ message: 'not found' })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default [ | ||
{ slug: 'foo', title: 'once upon a foo' }, | ||
{ slug: 'bar', title: 'a bar is born' }, | ||
{ slug: 'baz', title: 'bazzily ever after' } | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<script context="module"> | ||
export function preload() { | ||
return this.fetch('blog.json').then(r => r.json()).then(posts => { | ||
return { posts }; | ||
}); | ||
} | ||
</script> | ||
|
||
<script> | ||
export let posts; | ||
</script> | ||
|
||
<h1>blog</h1> | ||
|
||
{#each posts as post} | ||
<p><a href="blog/{post.slug}">{post.title}</a></p> | ||
{/each} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import posts from './_posts.js'; | ||
|
||
export function get(req, res) { | ||
res.writeHead(200, { | ||
'Content-Type': 'application/json' | ||
}); | ||
|
||
res.end(JSON.stringify(posts)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<h1>Great success!</h1> | ||
|
||
<a href="blog">blog</a> | ||
<a href="">empty anchor</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import sirv from 'sirv'; | ||
import polka from 'polka'; | ||
import * as sapper from '@sapper/server'; | ||
|
||
const { PORT, NODE_ENV } = process.env; | ||
const dev = NODE_ENV === 'development'; | ||
|
||
polka() | ||
.use( | ||
sirv('static', { dev }), | ||
sapper.middleware() | ||
) | ||
.listen(PORT, err => { | ||
if (err) console.log('error', err); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hiding whitespace will make the diff below a lot easier to read.