11'use client'
22
33import { useState , useEffect } from 'react'
4+ import Link from 'next/link'
45import { motion , AnimatePresence } from 'framer-motion'
56import { Menu , X , Clock } from 'lucide-react'
67
@@ -36,7 +37,8 @@ const Navbar = () => {
3637 { href : '#projects' , label : 'Projects' } ,
3738 { href : '#about' , label : 'About me' } ,
3839 { href : '#contact' , label : 'Contact' } ,
39- { href : '#sponsor' , label : 'Sponsor' }
40+ { href : '#sponsor' , label : 'Sponsor' } ,
41+ { href : '/blogs' , label : 'Blogs' , external : true }
4042 ]
4143
4244 const handleMenuClick = ( href : string ) => {
@@ -48,6 +50,8 @@ const Navbar = () => {
4850 }
4951 }
5052
53+ const isHashLink = ( href : string ) => href . startsWith ( '#' )
54+
5155 return (
5256 < >
5357 { /* Neon Clock */ }
@@ -86,27 +90,50 @@ const Navbar = () => {
8690 { /* Desktop Menu */ }
8791 < div className = "hidden md:block" >
8892 < div className = "ml-10 flex items-baseline space-x-8" >
89- { menuItems . map ( ( item , index ) => (
90- < motion . a
91- key = { item . href }
92- href = { item . href }
93- onClick = { ( e ) => {
94- e . preventDefault ( )
95- handleMenuClick ( item . href )
96- } }
97- className = "text-gray-300 hover:text-primary px-3 py-2 text-sm font-medium transition-all duration-300 relative group cursor-pointer"
98- initial = { { opacity : 0 , y : - 20 } }
99- animate = { { opacity : 1 , y : 0 } }
100- transition = { { duration : 0.5 , delay : 0.1 * index } }
101- whileHover = { { scale : 1.05 } }
102- >
103- { item . label }
104- < motion . div
105- className = "absolute bottom-0 left-0 w-0 h-0.5 bg-gradient-to-r from-primary to-blue-400 group-hover:w-full transition-all duration-300"
106- whileHover = { { width : '100%' } }
107- />
108- </ motion . a >
109- ) ) }
93+ { menuItems . map ( ( item , index ) => {
94+ const linkClasses = "text-gray-300 hover:text-primary px-3 py-2 text-sm font-medium transition-all duration-300 relative group cursor-pointer"
95+ if ( isHashLink ( item . href ) ) {
96+ return (
97+ < motion . a
98+ key = { item . href }
99+ href = { item . href }
100+ onClick = { ( e ) => {
101+ e . preventDefault ( )
102+ handleMenuClick ( item . href )
103+ } }
104+ className = { linkClasses }
105+ initial = { { opacity : 0 , y : - 20 } }
106+ animate = { { opacity : 1 , y : 0 } }
107+ transition = { { duration : 0.5 , delay : 0.1 * index } }
108+ whileHover = { { scale : 1.05 } }
109+ >
110+ { item . label }
111+ < motion . div
112+ className = "absolute bottom-0 left-0 w-0 h-0.5 bg-gradient-to-r from-primary to-blue-400 group-hover:w-full transition-all duration-300"
113+ whileHover = { { width : '100%' } }
114+ />
115+ </ motion . a >
116+ )
117+ }
118+
119+ return (
120+ < motion . div
121+ key = { item . href }
122+ initial = { { opacity : 0 , y : - 20 } }
123+ animate = { { opacity : 1 , y : 0 } }
124+ transition = { { duration : 0.5 , delay : 0.1 * index } }
125+ whileHover = { { scale : 1.05 } }
126+ >
127+ < Link
128+ href = { item . href }
129+ className = { linkClasses }
130+ >
131+ { item . label }
132+ < span className = "absolute bottom-0 left-0 w-0 h-0.5 bg-gradient-to-r from-primary to-blue-400 group-hover:w-full transition-all duration-300" />
133+ </ Link >
134+ </ motion . div >
135+ )
136+ } ) }
110137 </ div >
111138 </ div >
112139
@@ -156,23 +183,46 @@ const Navbar = () => {
156183 transition = { { duration : 0.3 } }
157184 >
158185 < div className = "px-2 pt-2 pb-3 space-y-1 sm:px-3" >
159- { menuItems . map ( ( item , index ) => (
160- < motion . a
161- key = { item . href }
162- href = { item . href }
163- onClick = { ( e ) => {
164- e . preventDefault ( )
165- handleMenuClick ( item . href )
166- } }
167- className = "text-gray-300 hover:text-primary hover:bg-gray-700/50 block px-3 py-2 text-base font-medium rounded-md transition-colors duration-200 cursor-pointer"
168- initial = { { opacity : 0 , x : - 20 } }
169- animate = { { opacity : 1 , x : 0 } }
170- transition = { { duration : 0.3 , delay : 0.1 * index } }
171- whileHover = { { x : 10 } }
172- >
173- { item . label }
174- </ motion . a >
175- ) ) }
186+ { menuItems . map ( ( item , index ) => {
187+ const linkClasses = "text-gray-300 hover:text-primary hover:bg-gray-700/50 block px-3 py-2 text-base font-medium rounded-md transition-colors duration-200 cursor-pointer"
188+ if ( isHashLink ( item . href ) ) {
189+ return (
190+ < motion . a
191+ key = { item . href }
192+ href = { item . href }
193+ onClick = { ( e ) => {
194+ e . preventDefault ( )
195+ handleMenuClick ( item . href )
196+ } }
197+ className = { linkClasses }
198+ initial = { { opacity : 0 , x : - 20 } }
199+ animate = { { opacity : 1 , x : 0 } }
200+ transition = { { duration : 0.3 , delay : 0.1 * index } }
201+ whileHover = { { x : 10 } }
202+ >
203+ { item . label }
204+ </ motion . a >
205+ )
206+ }
207+
208+ return (
209+ < motion . div
210+ key = { item . href }
211+ initial = { { opacity : 0 , x : - 20 } }
212+ animate = { { opacity : 1 , x : 0 } }
213+ transition = { { duration : 0.3 , delay : 0.1 * index } }
214+ whileHover = { { x : 10 } }
215+ >
216+ < Link
217+ href = { item . href }
218+ className = { linkClasses }
219+ onClick = { ( ) => setIsOpen ( false ) }
220+ >
221+ { item . label }
222+ </ Link >
223+ </ motion . div >
224+ )
225+ } ) }
176226 </ div >
177227 </ motion . div >
178228 ) }
0 commit comments