Created
October 18, 2019 10:08
-
-
Save smokeyfro/bdc9278efcd9576da46446d28ae78f8c to your computer and use it in GitHub Desktop.
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
<script context="module"> | |
import blocksToHtml from '@sanity/block-content-to-html' | |
import client from '../../sanityClient' | |
import serializers from '../../components/serializers' | |
export function preload({ params, query }) { | |
const projection = `{ | |
..., | |
excerpt[]{ | |
... | |
} | |
}` | |
return client.fetch('*[_type == "theme" && defined(slug.current)]').then(themes => { | |
return { themes: { | |
...theme, | |
excerpt: blocksToHtml({blocks: post.excerpt, serializers, ...client.clientConfig }) | |
} | |
}; | |
}).catch(err => this.error(500, err)); | |
} | |
</script> | |
<script> | |
export let themes; | |
export let theme; | |
</script> | |
<style> | |
ul { | |
margin: 0 0 1em 0; | |
line-height: 1.5; | |
} | |
</style> | |
<svelte:head> | |
<title>Themes</title> | |
</svelte:head> | |
<h1>Themes</h1> | |
<ul> | |
{#each themes as theme} | |
<!-- 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='tuts/{theme.slug.current}'> | |
<h2>{theme.title}</h2> | |
<p>{theme.excerpt}</p> | |
</a> | |
</li> | |
{/each} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment