73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import React, { Suspense } from 'react'
|
||
import type { Metadata } from 'next'
|
||
import SearchCard from '../components/SearchCard'
|
||
import { SearchCardProps, SearchPageProps } from '@/app/types'
|
||
import { fetchRoutes } from '@/lib/search/fetchRoutes'
|
||
|
||
export async function generateMetadata(): Promise<Metadata> {
|
||
return {
|
||
title: 'Поиск перевозчиков и посылок | Tripwb',
|
||
description:
|
||
'Найдите самые быстрые варианты по перевозке своих посылок | Tripwb - текст текст текст',
|
||
openGraph: {
|
||
title: 'Поиск текст текст | Tripwb - текст текст текст',
|
||
description: 'Найдите лучшие что то',
|
||
url: 'https://tripwb.com/search',
|
||
siteName: 'TripWB',
|
||
images: [
|
||
{
|
||
url: 'https://i.ibb.co/gmqzzmb/header-logo-mod-1200x630.png',
|
||
width: 1200,
|
||
height: 630,
|
||
alt: 'Tripwb - текст текст текст',
|
||
},
|
||
],
|
||
locale: 'ru_RU',
|
||
type: 'website',
|
||
},
|
||
twitter: {
|
||
card: 'summary_large_image',
|
||
title: 'Поиск текст текст | TripWB',
|
||
description: 'Ттекст текст текст текст',
|
||
images: [
|
||
{
|
||
url: 'https://i.ibb.co/gmqzzmb/header-logo-mod-1200x630.png',
|
||
width: 1200,
|
||
height: 630,
|
||
alt: 'Tripwb - текст текст текст',
|
||
},
|
||
],
|
||
},
|
||
alternates: {
|
||
canonical: 'https://tripwb.com/search/',
|
||
},
|
||
robots: {
|
||
index: true,
|
||
follow: true,
|
||
},
|
||
}
|
||
}
|
||
|
||
export default async function SearchPage(props: SearchPageProps) {
|
||
const params = await props.params
|
||
const { results, count } = await fetchRoutes(params.category || '')
|
||
|
||
return (
|
||
<div className="container mx-auto p-4">
|
||
<h1 className="mb-4 text-2xl font-bold">
|
||
{params.category === 'mover' ? 'Поиск перевозчика' : 'Поиск посылки'}
|
||
</h1>
|
||
|
||
<Suspense fallback={<div>Загрузка результатов...</div>}>
|
||
<div className="space-y-4">
|
||
{results.length > 0 ? (
|
||
results.map((item: SearchCardProps) => <SearchCard key={item.id} {...item} />)
|
||
) : (
|
||
<div className="text-center text-gray-500">Объявления не найдены</div>
|
||
)}
|
||
</div>
|
||
</Suspense>
|
||
</div>
|
||
)
|
||
}
|