@@ -9,14 +9,12 @@ import { useLocation } from 'react-router-dom'
9
9
import toast from 'react-hot-toast'
10
10
import { Badge } from '@web-archive/shared/components/badge'
11
11
import ScreenshotView from './screenshot-view'
12
- import { useNavigate } from '~/router'
13
12
import { updatePageShowcase } from '~/data/page'
14
13
import CardEditDialog from '~/components/card-edit-dialog'
15
14
import TagContext from '~/store/tag'
15
+ import { Link } from '~/router'
16
16
17
17
function Comp ( { page, onPageDelete } : { page : Page , onPageDelete ?: ( page : Page ) => void } ) {
18
- const navigate = useNavigate ( )
19
-
20
18
const { tagCache, refreshTagCache } = useContext ( TagContext )
21
19
const bindTags = tagCache ?. filter ( tag => tag . pageIds . includes ( page . id ) ) ?? [ ]
22
20
const tagBadgeList = bindTags . map ( ( tag ) => {
@@ -25,10 +23,7 @@ function Comp({ page, onPageDelete }: { page: Page, onPageDelete?: (page: Page)
25
23
26
24
const location = useLocation ( )
27
25
const isShowcased = location . pathname . startsWith ( '/showcase' )
28
-
29
- const handleClickPageCard = ( page : Page ) => {
30
- navigate ( isShowcased ? '/showcase/page/:slug' : '/page/:slug' , { params : { slug : String ( page . id ) } } )
31
- }
26
+ const redirectTo = isShowcased ? `/showcase/page/:slug` : `/page/:slug`
32
27
33
28
const handleClickPageUrl = ( e : React . MouseEvent , page : Page ) => {
34
29
e . stopPropagation ( )
@@ -68,26 +63,29 @@ function Comp({ page, onPageDelete }: { page: Page, onPageDelete?: (page: Page)
68
63
< CardEditDialog open = { openCardEditDialog } onOpenChange = { setOpenCardEditDialog } pageId = { page . id } />
69
64
)
70
65
}
66
+
71
67
< Card
72
68
key = { page . id }
73
- onClick = { ( ) => handleClickPageCard ( page ) }
74
69
className = "cursor-pointer hover:shadow-lg transition-shadow flex flex-col relative group overflow-hidden"
75
70
>
76
- < CardHeader >
77
- < CardTitle className = "leading-8 text-lg line-clamp-2" > { page . title } </ CardTitle >
78
- < CardDescription className = "space-x-1" >
79
- { tagBadgeList }
80
- </ CardDescription >
81
- </ CardHeader >
82
- < CardContent className = "flex-1" >
83
- < ScreenshotView
84
- screenshotId = { page . screenshotId }
85
- className = "w-full mb-2"
86
- loadingClassName = "w-full h-48"
87
- >
88
- </ ScreenshotView >
89
- < p className = "h-auto text-sm text-gray-600 dark:text-gray-400 line-clamp-3" > { page . pageDesc } </ p >
90
- </ CardContent >
71
+ < Link to = { redirectTo } params = { { slug : page . id . toString ( ) } } >
72
+ < CardHeader >
73
+ < CardTitle className = "leading-8 text-lg line-clamp-2" > { page . title } </ CardTitle >
74
+ < CardDescription className = "space-x-1" >
75
+ { tagBadgeList }
76
+ </ CardDescription >
77
+ </ CardHeader >
78
+ < CardContent className = "flex-1" >
79
+ < ScreenshotView
80
+ screenshotId = { page . screenshotId }
81
+ className = "w-full mb-2"
82
+ loadingClassName = "w-full h-48"
83
+ >
84
+ </ ScreenshotView >
85
+ < p className = "h-auto text-sm text-gray-600 dark:text-gray-400 line-clamp-3" > { page . pageDesc } </ p >
86
+ </ CardContent >
87
+ </ Link >
88
+
91
89
< CardFooter className = "flex space-x-2 justify-end w-full backdrop-blur-sm py-4 absolute bottom-0 group-hover:opacity-100 sm:opacity-0 transition-opacity" >
92
90
{
93
91
! isShowcased && (
0 commit comments