-
-
Notifications
You must be signed in to change notification settings - Fork 207
/
Copy pathheader.js
48 lines (44 loc) · 1.12 KB
/
header.js
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
41
42
43
44
45
46
47
48
import React from 'react'
import Head from 'next/head'
import Link from 'next/link'
import Router from 'next/router'
import useTranslation from 'next-translate/useTranslation'
import styles from './header.module.css'
export default function Header() {
const { t, lang } = useTranslation()
const title = t('common:title')
function changeToEn() {
Router.push('/', undefined, { locale: 'en' })
}
return (
<>
<Head>
<title>
{title} | ({lang.toUpperCase()})
</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<header className={styles.header}>
<h1>{title}</h1>
{lang !== 'es' && (
<Link href="/" locale="es">
<a>Español</a>
</Link>
)}
{lang !== 'ca' && (
<Link href="/" locale="ca">
<a>Català</a>
</Link>
)}
{lang !== 'en' && (
<>
<Link href="/" locale="en">
<a>English</a>
</Link>
<button onClick={changeToEn}>English Router.push</button>
</>
)}
</header>
</>
)
}