Open History to see the last commit
1<script lang="ts">
2 import { resolve } from '$app/paths'
3 import { createQuery } from '@tanstack/svelte-query'
4 import { postsQueries } from './services/posts/queries'
5β
6 type Props = {
7 postId: number
8 }
9β
10 let { postId }: Props = $props()
11β
12 const post = createQuery(() => postsQueries.detail(postId))
13</script>
14β
15<div>
16 <div>
17 <a class="button" href={resolve('/')}> Back </a>
18 </div>
19 {#if post.isPending}
20 <span>Loading...</span>
21 {/if}
22 {#if post.error}
23 <span>Error: {post.error.message}</span>
24 {/if}
25 {#if post.isSuccess}
26 <h1>{post.data.title}</h1>
27 <div>
28 <p>{post.data.body}</p>
29 </div>
30 <div>{post.isFetching ? 'Background Updating...' : ' '}</div>
31 {/if}
32</div>