@@ -5,6 +5,8 @@ import CommentBtn from '../../components/comment/CommentBtn';
55import LikeBtn from '../../components/like/LikeBtn' ;
66import ShareModal from '@/domains/shared/components/share/ShareModal' ;
77import { RefObject , useState } from 'react' ;
8+ import { useParams } from 'next/navigation' ;
9+ import { CommentType } from '../../types/post' ;
810
911type Props = {
1012 likeCount : number ;
@@ -14,6 +16,7 @@ type Props = {
1416 onLikeToggle : ( ) => void ;
1517 title : string ;
1618 imageUrls : string [ ] ;
19+ comments : CommentType [ ] | null ;
1720} ;
1821
1922interface Meta {
@@ -30,10 +33,14 @@ function DetailTabDesktop({
3033 onLikeToggle,
3134 title,
3235 imageUrls,
36+ comments,
3337} : Props ) {
3438 const [ isShare , setIsShare ] = useState ( false ) ;
3539 const [ meta , setMeta ] = useState < Meta | null > ( null ) ;
3640
41+ const params = useParams ( ) ;
42+ const postId = params ?. id ;
43+
3744 const handleClick = ( ) => {
3845 if ( commentRef . current ) {
3946 const top = commentRef . current . getBoundingClientRect ( ) . top + window . scrollY - 100 ; // 100px 위로 offset
@@ -43,15 +50,13 @@ function DetailTabDesktop({
4350
4451 // ✅ 공유 버튼 클릭 시 meta 생성
4552 const handleShareClick = ( ) => {
46- if ( typeof window !== 'undefined' ) {
47- const currentUrl = window . location . href ;
48- setMeta ( {
49- title,
50- url : currentUrl ,
51- imageUrl : imageUrls [ 0 ] || getOgImage ( ) ,
52- } ) ;
53- setIsShare ( true ) ;
54- }
53+ const currentUrl = `http://www.ssoul.life/community/${ postId } ` ;
54+ setMeta ( {
55+ title,
56+ url : currentUrl ,
57+ imageUrl : imageUrls [ 0 ] || getOgImage ( ) ,
58+ } ) ;
59+ setIsShare ( true ) ;
5560 } ;
5661
5762 // ✅ og:image 메타태그에서 이미지 가져오기 (fallback용)
@@ -64,7 +69,7 @@ function DetailTabDesktop({
6469 < >
6570 < section
6671 aria-label = "게시글 인터랙션 버튼"
67- className = "absolute top-[50px] 2xl:right-80 xl:right-50 lg:right-10 md:right-10 z-10 h-full transition-transform duration-300 ease-in-out"
72+ className = "absolute top-[50px] 2xl:right-60 xl:right-50 lg:right-10 md:right-10 z-10 h-full transition-transform duration-300 ease-in-out"
6873 >
6974 < div className = "sticky top-[183px]" >
7075 < div className = "flex md:flex-col md:gap-10 w-full h-full" >
@@ -74,7 +79,7 @@ function DetailTabDesktop({
7479 </ div >
7580 < div className = "flex md:flex-col justify-center items-center gap-2 text-sm text-gray" >
7681 < CommentBtn size = "md" onClick = { handleClick } />
77- < span > { commentCount } </ span >
82+ < span > { comments ?. length } </ span >
7883 </ div >
7984 < div >
8085 < Share variants = "community" size = "md" onClick = { handleShareClick } />
0 commit comments