Skip to content

Commit 38655f2

Browse files
committed
fix: activity card like type render
Signed-off-by: Innei <i@innei.in>
1 parent 84cea05 commit 38655f2

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

src/app/(app)/(home)/components/ActivityCard.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use client'
22

3-
import React, { useMemo } from 'react'
3+
import { useMemo } from 'react'
44
import clsx from 'clsx'
55
import Link from 'next/link'
66
import RemoveMarkdown from 'remove-markdown'
7+
import type { ReactNode } from 'react'
78
import type { ReactActivityType } from './types'
89

910
import { CollectionRefTypes } from '@mx-space/api-client'
@@ -149,22 +150,35 @@ export const ActivityCard = ({ activity }: { activity: ReactActivityType }) => {
149150
)
150151
}
151152
case 'like': {
153+
let TitleLink: ReactNode = null
154+
switch (activity.type) {
155+
case CollectionRefTypes.Post: {
156+
TitleLink = (
157+
<Link href={`/posts/${activity.slug}`}>
158+
<b>{activity.title}</b>
159+
</Link>
160+
)
161+
break
162+
}
163+
case CollectionRefTypes.Note: {
164+
TitleLink = (
165+
<Link href={`/notes/${activity.nid}`}>
166+
<b>{activity.title}</b>
167+
</Link>
168+
)
169+
break
170+
}
171+
default: {
172+
TitleLink = <b>已删除的内容</b>
173+
}
174+
}
152175
return (
153176
<div className="flex translate-y-1/4 items-start gap-2">
154177
<span className={clsx(iconClassName)}>
155178
<i className="icon-[mingcute--heart-line]" />
156179
</span>
157180
<div className="space-x-2">
158-
<small>有人点赞了</small>{' '}
159-
<Link
160-
href={
161-
activity.slug
162-
? `/posts/${activity.slug}`
163-
: `/notes/${activity.nid}`
164-
}
165-
>
166-
<b>{activity.title}</b>
167-
</Link>
181+
<small>有人点赞了</small> {TitleLink}
168182
</div>
169183
</div>
170184
)

src/app/(app)/(home)/components/ActivityRecent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useQuery } from '@tanstack/react-query'
4-
import React, { useMemo } from 'react'
4+
import { useMemo } from 'react'
55
import clsx from 'clsx'
66
import { m } from 'framer-motion'
77
import type { ReactActivityType } from './types'

0 commit comments

Comments
 (0)