-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.jsx
More file actions
40 lines (34 loc) · 1.32 KB
/
Header.jsx
File metadata and controls
40 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, { useState, useEffect } from 'react'
import Link from 'next/link';
import { getCategories } from '../services';
const Header = () => {
const [categories, setCategories] = useState([]);
useEffect(() => {
getCategories().then((newCategories) => {
setCategories(newCategories);
});
}, []);
return (
<div className="container mx-auto px-10 mb-8">
<div className="border-b w-full inline-block border-blue-400 py-8">
<div className="md:float-left block">
<Link href="/">
<span className="cursor-pointer font-bold text-4xl text-white">
BlogMesh
</span>
</Link>
</div>
<div className="hidden md:float-left md:contents">
{categories.map((category, index) => (
<Link key={index} href={`/category/${category.slug}`}>
<span className="md:float-right mt-2 align-middle text-white ml-4 font-semibold cursor-pointer">
{category.name}
</span>
</Link>
))}
</div>
</div>
</div>
);
}
export default Header