@@ -3,126 +3,129 @@ import Link from 'next/link';
3
3
import { useState } from 'react' ;
4
4
import NavTopic from '../navTopic' ;
5
5
import { chapters } from '@/content' ;
6
+ import { usePathname } from 'next/navigation' ;
6
7
7
8
const Navbar = ( ) => {
8
9
const [ isDropdownVisible , setDropdownVisible ] = useState ( false ) ;
10
+ const pathname = usePathname ( ) ;
9
11
10
12
const toggleMenu = ( ) => {
11
13
setDropdownVisible ( ! isDropdownVisible ) ;
12
14
} ;
13
15
14
16
const splitIndex = Math . ceil ( chapters . length / 2 ) ;
15
17
16
- return (
17
- < nav className = 'bg-white border-gray-200 md:hidden ' >
18
- < div className = 'flex flex-wrap justify-between items-center mx-auto max-w-screen-xl p-4' >
19
- < Link
20
- href = '/'
21
- className = 'flex items-center space-x-3 rtl:space-x-reverse'
22
- >
23
- < span className = 'self-center text-2xl font-bold text-gray-900 whitespace-nowrap font-stretch' >
24
- LC
25
- </ span >
26
- </ Link >
18
+ if ( ! pathname . includes ( 'quiz' ) )
19
+ return (
20
+ < nav className = 'bg-white border-gray-200 md:hidden ' >
21
+ < div className = 'flex flex-wrap justify-between items-center mx-auto max-w-screen-xl p-4' >
22
+ < Link
23
+ href = '/'
24
+ className = 'flex items-center space-x-3 rtl:space-x-reverse'
25
+ >
26
+ < span className = 'self-center text-2xl font-bold text-gray-900 whitespace-nowrap font-stretch' >
27
+ LogiCola
28
+ </ span >
29
+ </ Link >
27
30
28
- < button
29
- type = 'button'
30
- className = 'inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-stone-200 '
31
- onClick = { ( ) => setDropdownVisible ( ! isDropdownVisible ) }
32
- >
33
- < span className = 'sr-only' > Open main menu</ span >
34
- < svg
35
- className = 'w-5 h-5'
36
- aria-hidden = 'true'
37
- xmlns = 'http://www.w3.org/2000/svg'
38
- fill = 'none'
39
- viewBox = '0 0 17 14'
31
+ < button
32
+ type = 'button'
33
+ className = 'inline-flex items-center p-2 w-10 h-10 justify-center text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-200 focus:outline-none focus:ring-2 focus:ring-stone-200 '
34
+ onClick = { ( ) => setDropdownVisible ( ! isDropdownVisible ) }
40
35
>
41
- < path
42
- stroke = 'currentColor'
43
- strokeLinecap = 'round '
44
- strokeLinejoin = 'round '
45
- strokeWidth = '2 '
46
- d = 'M1 1h15M1 7h15M1 13h15 '
47
- />
48
- </ svg >
49
- </ button >
50
- < div
51
- className = { `items-center justify-between font-semibold w-full md:flex md:w-auto md:order-1 hidden` }
52
- >
53
- < ul className = 'flex flex-col p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:space-x-8 rtl:space-x-reverse md:flex-row md:mt-0 md:border-0 md:bg-white' >
54
- < li >
55
- < button
56
- type = 'button'
57
- onMouseEnter = { toggleMenu }
58
- id = 'mega-menu-full-dropdown-button'
59
- data-collapse-toggle = 'mega-menu- full-dropdown'
60
- className = 'flex items-center justify-between w-full py-2 px-3 text-gray-500 rounded md:w-auto hover:bg-gray-200 md:border-0 md:hover:text-primaryColor'
61
- >
62
- Chapters { ' ' }
63
- < svg
64
- className = 'w-2.5 h-2.5 ms-2.5 '
65
- aria-hidden = 'true'
66
- xmlns = 'http://www.w3.org/2000/svg '
67
- fill = 'none '
68
- viewBox = '0 0 10 6 '
36
+ < span className = 'sr-only' > Open main menu </ span >
37
+ < svg
38
+ className = 'w-5 h-5 '
39
+ aria-hidden = 'true '
40
+ xmlns = 'http://www.w3.org/2000/svg '
41
+ fill = 'none '
42
+ viewBox = '0 0 17 14'
43
+ >
44
+ < path
45
+ stroke = 'currentColor'
46
+ strokeLinecap = 'round'
47
+ strokeLinejoin = 'round'
48
+ strokeWidth = '2'
49
+ d = 'M1 1h15M1 7h15M1 13h15'
50
+ />
51
+ </ svg >
52
+ </ button >
53
+ < div
54
+ className = { `items-center justify-between font-semibold w- full md:flex md:w-auto md:order-1 hidden` }
55
+ >
56
+ < ul className = 'flex flex-col p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:space-x-8 rtl:space-x-reverse md:flex-row md:mt-0 md:border-0 md:bg-white' >
57
+ < li >
58
+ < button
59
+ type = 'button '
60
+ onMouseEnter = { toggleMenu }
61
+ id = 'mega-menu-full-dropdown-button '
62
+ data-collapse-toggle = 'mega-menu-full-dropdown '
63
+ className = 'flex items-center justify-between w-full py-2 px-3 text-gray-500 rounded md:w-auto hover:bg-gray-200 md:border-0 md:hover:text-primaryColor '
69
64
>
70
- < path
71
- stroke = 'currentColor'
72
- strokeLinecap = 'round'
73
- strokeLinejoin = 'round'
74
- strokeWidth = '2'
75
- d = 'm1 1 4 4 4-4'
76
- />
77
- </ svg >
78
- </ button >
79
- </ li >
65
+ Chapters{ ' ' }
66
+ < svg
67
+ className = 'w-2.5 h-2.5 ms-2.5'
68
+ aria-hidden = 'true'
69
+ xmlns = 'http://www.w3.org/2000/svg'
70
+ fill = 'none'
71
+ viewBox = '0 0 10 6'
72
+ >
73
+ < path
74
+ stroke = 'currentColor'
75
+ strokeLinecap = 'round'
76
+ strokeLinejoin = 'round'
77
+ strokeWidth = '2'
78
+ d = 'm1 1 4 4 4-4'
79
+ />
80
+ </ svg >
81
+ </ button >
82
+ </ li >
80
83
81
- < li >
82
- < Link
83
- href = 'https://github.com/sponsors/malikpiara'
84
- className = 'block py-2 px-3 text-gray-500 rounded hover:bg-gray-200 md:hover:text-primaryColor'
85
- >
86
- Donate
87
- </ Link >
88
- </ li >
89
- </ ul >
84
+ < li >
85
+ < Link
86
+ href = 'https://github.com/sponsors/malikpiara'
87
+ className = 'block py-2 px-3 text-gray-500 rounded hover:bg-gray-200 md:hover:text-primaryColor'
88
+ >
89
+ Donate
90
+ </ Link >
91
+ </ li >
92
+ </ ul >
93
+ </ div >
90
94
</ div >
91
- </ div >
92
- < div
93
- id = 'mega-menu-full-dropdown'
94
- onMouseLeave = { toggleMenu }
95
- className = { ` ${
96
- ! isDropdownVisible && 'hidden'
97
- } border-gray-200 shadow-sm bg-gray-50 md:bg-white absolute w-full z-50` }
98
- >
99
- < div className = 'grid max-w-screen-xl px-4 py-5 mx-auto text-gray-900 sm:grid-cols-2 md:px-6 shadow-sm' >
100
- < ul >
101
- { chapters . slice ( 0 , splitIndex ) . map ( ( i ) => (
102
- < NavTopic
103
- key = { i . id }
104
- chapter = { i . set }
105
- title = { i . title }
106
- path = { '/' + i . slugs . join ( '/' ) + '/quiz' }
107
- newLabel = { i . isNew }
108
- />
109
- ) ) }
110
- </ ul >
111
- < ul >
112
- { chapters . slice ( splitIndex ) . map ( ( i ) => (
113
- < NavTopic
114
- key = { i . id }
115
- chapter = { i . set }
116
- title = { i . title }
117
- path = { '/' + i . slugs . join ( '/' ) + '/quiz' }
118
- newLabel = { i . isNew }
119
- />
120
- ) ) }
121
- </ ul >
95
+ < div
96
+ id = 'mega-menu-full-dropdown'
97
+ onMouseLeave = { toggleMenu }
98
+ className = { ` ${
99
+ ! isDropdownVisible && 'hidden'
100
+ } border-gray-200 shadow-sm bg-gray-50 md:bg-white absolute w-full z-50` }
101
+ >
102
+ < div className = 'grid max-w-screen-xl px-4 py-5 mx-auto text-gray-900 sm:grid-cols-2 md:px-6 shadow-sm' >
103
+ < ul >
104
+ { chapters . slice ( 0 , splitIndex ) . map ( ( i ) => (
105
+ < NavTopic
106
+ key = { i . id }
107
+ chapter = { i . set }
108
+ title = { i . title }
109
+ path = { '/' + i . slugs . join ( '/' ) + '/quiz' }
110
+ newLabel = { i . isNew }
111
+ />
112
+ ) ) }
113
+ </ ul >
114
+ < ul >
115
+ { chapters . slice ( splitIndex ) . map ( ( i ) => (
116
+ < NavTopic
117
+ key = { i . id }
118
+ chapter = { i . set }
119
+ title = { i . title }
120
+ path = { '/' + i . slugs . join ( '/' ) + '/quiz' }
121
+ newLabel = { i . isNew }
122
+ />
123
+ ) ) }
124
+ </ ul >
125
+ </ div >
122
126
</ div >
123
- </ div >
124
- </ nav >
125
- ) ;
127
+ </ nav >
128
+ ) ;
126
129
} ;
127
130
128
131
export default Navbar ;
0 commit comments