diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts index 38fb8deb..2ab3afcd 100644 --- a/ui/src/common/interface.ts +++ b/ui/src/common/interface.ts @@ -334,6 +334,7 @@ export interface SearchResItem { object_type: string; object: { id: string; + question_id?: string; title: string; excerpt: string; created_at: number; diff --git a/ui/src/pages/Search/components/SearchItem/index.tsx b/ui/src/pages/Search/components/SearchItem/index.tsx index 8b9d8e6e..ad08aa5e 100644 --- a/ui/src/pages/Search/components/SearchItem/index.tsx +++ b/ui/src/pages/Search/components/SearchItem/index.tsx @@ -14,6 +14,10 @@ const Index: FC = ({ data }) => { if (!data?.object_type) { return null; } + let itemUrl = `/questions/${data.object.id}`; + if (data.object_type === 'answer') { + itemUrl = `/questions/${data.object.question_id}/${data.object.id}`; + } return (
@@ -23,9 +27,7 @@ const Index: FC = ({ data }) => { style={{ marginTop: '2px' }}> {data.object_type === 'question' ? 'Q' : 'A'} - + {data.object.title} {data.object.status === 'closed' ? ` [${t('closed', { keyPrefix: 'question' })}]`