fix(search): complete href for SearchItem answer

This commit is contained in:
haitao(lj) 2022-11-17 14:42:23 +08:00
parent 1590b662f6
commit aeb60ffa38
2 changed files with 6 additions and 3 deletions

View File

@ -334,6 +334,7 @@ export interface SearchResItem {
object_type: string;
object: {
id: string;
question_id?: string;
title: string;
excerpt: string;
created_at: number;

View File

@ -14,6 +14,10 @@ const Index: FC<Props> = ({ 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 (
<ListGroupItem className="py-3 px-0">
<div className="mb-2 clearfix">
@ -23,9 +27,7 @@ const Index: FC<Props> = ({ data }) => {
style={{ marginTop: '2px' }}>
{data.object_type === 'question' ? 'Q' : 'A'}
</Badge>
<a
className="h5 mb-0 link-dark text-break"
href={`/questions/${data.object.id}`}>
<a className="h5 mb-0 link-dark text-break" href={itemUrl}>
{data.object.title}
{data.object.status === 'closed'
? ` [${t('closed', { keyPrefix: 'question' })}]`