Skip to content

Commit

Permalink
fix: home activity ref type link
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Apr 17, 2024
1 parent 5b9c380 commit 0bb00bd
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/app/(app)/(home)/components/ActivityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 (
<div className="relative flex flex-col justify-center gap-2">
<div
Expand All @@ -42,15 +63,13 @@ export const ActivityCard = ({ activity }: { activity: ReactActivityType }) => {
)}
<span className="font-medium">{activity.author}</span>{' '}
<small></small>{' '}
<Link
className="shiro-link--underline"
href={
activity.slug
? `/posts/${activity.slug}`
: `/notes/${activity.nid}`
}
>
<b>{activity.title}</b>
<Link className="shiro-link--underline" href={toLink}>
<b>
{activity.title ||
(activity.type === CollectionRefTypes.Recently
? '一条想法中'
: null)}
</b>
</Link>{' '}
<small>说:</small>
</div>
Expand Down

0 comments on commit 0bb00bd

Please sign in to comment.