You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
691 B
Svelte
34 lines
691 B
Svelte
4 years ago
|
<script context="module">
|
||
|
export function preload({ params, query }) {
|
||
|
return this.fetch(`blog.json`).then(r => r.json()).then(posts => {
|
||
|
return { posts };
|
||
|
});
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<script>
|
||
|
export let posts;
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
ul {
|
||
|
margin: 0 0 1em 0;
|
||
|
line-height: 1.5;
|
||
|
}
|
||
|
</style>
|
||
|
|
||
|
<svelte:head>
|
||
|
<title>Blog</title>
|
||
|
</svelte:head>
|
||
|
|
||
|
<h1>Recent posts</h1>
|
||
|
|
||
|
<ul>
|
||
|
{#each posts as post}
|
||
|
<!-- we're using the non-standard `rel=prefetch` attribute to
|
||
|
tell Sapper to load the data for the page as soon as
|
||
|
the user hovers over the link or taps it, instead of
|
||
|
waiting for the 'click' event -->
|
||
|
<li><a rel='prefetch' href='blog/{post.slug}'>{post.title}</a></li>
|
||
|
{/each}
|
||
|
</ul>
|