Skip to content

Commit

Permalink
fix: activity card like type render
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed May 3, 2024
1 parent 84cea05 commit 38655f2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
36 changes: 25 additions & 11 deletions src/app/(app)/(home)/components/ActivityCard.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client'

import React, { useMemo } from 'react'
import { useMemo } from 'react'
import clsx from 'clsx'
import Link from 'next/link'
import RemoveMarkdown from 'remove-markdown'
import type { ReactNode } from 'react'
import type { ReactActivityType } from './types'

import { CollectionRefTypes } from '@mx-space/api-client'
Expand Down Expand Up @@ -149,22 +150,35 @@ export const ActivityCard = ({ activity }: { activity: ReactActivityType }) => {
)
}
case 'like': {
let TitleLink: ReactNode = null
switch (activity.type) {
case CollectionRefTypes.Post: {
TitleLink = (
<Link href={`/posts/${activity.slug}`}>
<b>{activity.title}</b>
</Link>
)
break
}
case CollectionRefTypes.Note: {
TitleLink = (
<Link href={`/notes/${activity.nid}`}>
<b>{activity.title}</b>
</Link>
)
break
}
default: {
TitleLink = <b>已删除的内容</b>
}
}
return (
<div className="flex translate-y-1/4 items-start gap-2">
<span className={clsx(iconClassName)}>
<i className="icon-[mingcute--heart-line]" />
</span>
<div className="space-x-2">
<small>有人点赞了</small>{' '}
<Link
href={
activity.slug
? `/posts/${activity.slug}`
: `/notes/${activity.nid}`
}
>
<b>{activity.title}</b>
</Link>
<small>有人点赞了</small> {TitleLink}
</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/app/(app)/(home)/components/ActivityRecent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { useQuery } from '@tanstack/react-query'
import React, { useMemo } from 'react'
import { useMemo } from 'react'
import clsx from 'clsx'
import { m } from 'framer-motion'
import type { ReactActivityType } from './types'
Expand Down

0 comments on commit 38655f2

Please sign in to comment.