From 0bb00bdf365c439b83c57da4ec8d02e7703aa9ce Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 17 Apr 2024 20:58:15 +0800 Subject: [PATCH] fix: home activity ref type link Signed-off-by: Innei --- .../(app)/(home)/components/ActivityCard.tsx | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/app/(app)/(home)/components/ActivityCard.tsx b/src/app/(app)/(home)/components/ActivityCard.tsx index 9ee5a98506..268b56bd76 100644 --- a/src/app/(app)/(home)/components/ActivityCard.tsx +++ b/src/app/(app)/(home)/components/ActivityCard.tsx @@ -6,6 +6,8 @@ import Link from 'next/link' import RemoveMarkdown from 'remove-markdown' import type { ReactActivityType } from './types' +import { CollectionRefTypes } from '@mx-space/api-client' + import { FaSolidFeatherAlt, IcTwotoneSignpost, @@ -22,6 +24,25 @@ export const ActivityCard = ({ activity }: { activity: ReactActivityType }) => { const Content = useMemo(() => { switch (activity.bizType) { case 'comment': { + let toLink = '' + switch (activity.type) { + case CollectionRefTypes.Post: { + toLink = `/posts/${activity.slug}` + break + } + case CollectionRefTypes.Note: { + toLink = `/notes/${activity.nid}` + break + } + case CollectionRefTypes.Page: { + toLink = `/${activity.slug}` + break + } + case CollectionRefTypes.Recently: { + toLink = `/thinking/${activity.id}` + break + } + } return (
{ )} {activity.author}{' '} {' '} - - {activity.title} + + + {activity.title || + (activity.type === CollectionRefTypes.Recently + ? '一条想法中' + : null)} + {' '} 说: