Open History to see the last commit
1import { Link, createFileRoute } from '@tanstack/solid-router'
2import { fetchPost } from '../utils/posts'
3import { NotFound } from '~/components/NotFound'
4import { PostErrorComponent } from '~/components/PostError'
5β
6export const Route = createFileRoute('/posts/$postId')({
7 loader: ({ params: { postId } }) => fetchPost({ data: postId }),
8 errorComponent: PostErrorComponent,
9 component: PostComponent,
10 notFoundComponent: () => {
11 return <NotFound>Post not found</NotFound>
12 },
13})
14β
15function PostComponent() {
16 const post = Route.useLoaderData()
17β
18 return (
19 <div class="space-y-2">
20 <h4 class="text-xl font-bold underline">{post().title}</h4>
21 <div class="text-sm">{post().body}</div>
22 <Link
23 to="/posts/$postId/deep"
24 params={{
25 postId: post().id,
26 }}
27 activeProps={{ class: 'text-black font-bold' }}
28 class="block py-1 text-blue-800 hover:text-blue-600"
29 >
30 Deep View
31 </Link>
32 </div>
33 )
34}