import { useParams } from '@tanstack/react-router';
function CollectionDetailsPage() {
const { name } = useParams();
const { data: collections, isLoading, isError } = useQuery(['collections'], fetchCollections);
if (isLoading) return
Loading collection...
;
if (isError) return Failed to load collection. Please try again later.
;
const collection = collections?.find((col) => col.name === name);
if (!collection) return Collection not found.
;
return (
{collection.name}
{collection.description}
Articles
{collection.articles.map((article) => (
{article.title}
{article.content.substring(0, 100)}...
Read more
))}
);
}
export default CollectionDetailsPage;import { createFileRoute } from '@tanstack/react-router'
export const Route = createFileRoute('/collections/[name]')({
component: RouteComponent,
})
function RouteComponent() {
return Hello "/collections/[name]"!
}