Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

posts_.$postId.deep.tsx

24 lines742 Bytes

1import { Link, createFileRoute } from '@tanstack/solid-router'
2import { PostErrorComponent } from '~/components/PostErrorComponent'
3​
4import { fetchPost } from '~/utils/posts'
5​
6export const Route = createFileRoute('/posts_/$postId/deep')({
7 loader: async ({ params: { postId } }) => fetchPost({ data: postId }),
8 errorComponent: PostErrorComponent,
9 component: PostDeepComponent,
10})
11​
12function PostDeepComponent() {
13 const post = Route.useLoaderData()
14​
15 return (
16 <div class="p-2 space-y-2">
17 <Link to="/posts" class="block py-1 text-blue-800 hover:text-blue-600">
18 ← All Posts
19 </Link>
20 <h4 class="text-xl font-bold underline">{post().title}</h4>
21 <div class="text-sm">{post().body}</div>
22 </div>
23 )