nicco.io/src/routes/blog/index.svelte

30 lines
633 B
Svelte
Raw Normal View History

2021-08-21 11:12:25 +02:00
<script lang="ts" context="module">
import type { Load } from '@sveltejs/kit'
export const load: Load = async ({ fetch }) => {
return {
props: {
data: await fetch('/api/posts/*.json').then((r) => r.json()),
},
}
}
</script>
<script lang="ts">
import type { Post } from '$lib/api'
import SimplePage from '$lib/components/SimplePage.svelte'
import PostPreview from '$lib/components/PostPreview.svelte'
export let data: Post[]
</script>
<svelte:head>
<title>Blog</title>
</svelte:head>
<SimplePage title="Works">
{#each data as post}
<PostPreview {post} />
{/each}
</SimplePage>