1- const HomePage = ( { onNavigate } ) => {
1+ const HomePage = ( { onNavigate, onOpenContent } ) => {
22 const [ articles , setArticles ] = useState ( [ ] ) ;
33 const [ works , setWorks ] = useState ( [ ] ) ;
44 const [ loading , setLoading ] = useState ( true ) ;
@@ -42,10 +42,11 @@ const HomePage = ({ onNavigate }) => {
4242 < div className = "card-grid" >
4343 { articles . map ( ( article ) => (
4444 < Card key = { article . id } tag = { article . tag } title = { article . title } description = { article . description } meta = { article . date } onClick = { ( ) => {
45- const url = new URL ( window . location . href ) ;
46- url . searchParams . set ( 'open' , `article:${ article . slug } ` ) ;
47- url . hash = '#articles' ;
48- window . location . href = url . toString ( ) ;
45+ if ( onOpenContent ) {
46+ onOpenContent ( 'article' , article . slug ) ;
47+ } else {
48+ onNavigate ( 'articles' ) ;
49+ }
4950 } } />
5051 ) ) }
5152 </ div >
@@ -65,10 +66,11 @@ const HomePage = ({ onNavigate }) => {
6566 < div className = "card-grid" >
6667 { works . map ( ( work , index ) => (
6768 < Card key = { work . id } title = { work . title } description = { work . description } tag = { work . techStack [ 0 ] } onClick = { ( ) => {
68- const url = new URL ( window . location . href ) ;
69- url . searchParams . set ( 'open' , `work:${ work . slug } ` ) ;
70- url . hash = '#works' ;
71- window . location . href = url . toString ( ) ;
69+ if ( onOpenContent ) {
70+ onOpenContent ( 'work' , work . slug ) ;
71+ } else {
72+ onNavigate ( 'works' ) ;
73+ }
7274 } } />
7375 ) ) }
7476 </ div >
0 commit comments