aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/MainNav/MainNav.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-29 19:03:59 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-29 19:03:59 +0100
commit8fb5e4ef3ae925ebc6622711fb5c8c6147642cbc (patch)
tree9e99137a7b64ea7993a8311a7162336a551be8b2 /src/components/MainNav/MainNav.tsx
parent2bae7c43764df5678fe2fc2e68be11ae95d85a41 (diff)
parente4d5b8151802517b2943756fc0d09ffa95e2c4e2 (diff)
feat(i18n): replace linguijs with formatjs
Diffstat (limited to 'src/components/MainNav/MainNav.tsx')
-rw-r--r--src/components/MainNav/MainNav.tsx66
1 files changed, 59 insertions, 7 deletions
diff --git a/src/components/MainNav/MainNav.tsx b/src/components/MainNav/MainNav.tsx
index afc4193..a866b9c 100644
--- a/src/components/MainNav/MainNav.tsx
+++ b/src/components/MainNav/MainNav.tsx
@@ -1,6 +1,3 @@
-import { SetStateAction } from 'react';
-import Link from 'next/link';
-import { t } from '@lingui/macro';
import {
BlogIcon,
ContactIcon,
@@ -9,9 +6,12 @@ import {
HomeIcon,
ProjectsIcon,
} from '@components/Icons';
-import { mainNav } from '@config/nav';
-import styles from './MainNav.module.scss';
+import { NavItem } from '@ts/types/nav';
+import Link from 'next/link';
import { useRouter } from 'next/router';
+import { SetStateAction } from 'react';
+import { useIntl } from 'react-intl';
+import styles from './MainNav.module.scss';
const MainNav = ({
isOpened,
@@ -20,8 +20,52 @@ const MainNav = ({
isOpened: boolean;
setIsOpened: (value: SetStateAction<boolean>) => void;
}) => {
+ const intl = useIntl();
const router = useRouter();
+ const mainNavConfig: NavItem[] = [
+ {
+ id: 'home',
+ name: intl.formatMessage({
+ defaultMessage: 'Home',
+ description: 'MainNav: home link',
+ }),
+ slug: '/',
+ },
+ {
+ id: 'blog',
+ name: intl.formatMessage({
+ defaultMessage: 'Blog',
+ description: 'MainNav: blog link',
+ }),
+ slug: '/blog',
+ },
+ {
+ id: 'projects',
+ name: intl.formatMessage({
+ defaultMessage: 'Projects',
+ description: 'MainNav: projects link',
+ }),
+ slug: '/projets',
+ },
+ {
+ id: 'cv',
+ name: intl.formatMessage({
+ defaultMessage: 'Resume',
+ description: 'MainNav: resume link',
+ }),
+ slug: '/cv',
+ },
+ {
+ id: 'contact',
+ name: intl.formatMessage({
+ defaultMessage: 'Contact',
+ description: 'MainNav: contact link',
+ }),
+ slug: '/contact',
+ },
+ ];
+
const getIcon = (id: string) => {
switch (id) {
case 'home':
@@ -39,7 +83,7 @@ const MainNav = ({
}
};
- const navItems = mainNav.map((item) => {
+ const navItems = mainNavConfig.map((item) => {
const currentClass = router.asPath === item.slug ? styles.current : '';
return (
@@ -73,7 +117,15 @@ const MainNav = ({
>
<HamburgerIcon isActive={isOpened} />
<span className="screen-reader-text">
- {isOpened ? t`Close menu` : t`Open menu`}
+ {isOpened
+ ? intl.formatMessage({
+ defaultMessage: 'Close menu',
+ description: 'MainNav: close button',
+ })
+ : intl.formatMessage({
+ defaultMessage: 'Open menu',
+ description: 'MainNav: open button',
+ })}
</span>
</label>
<nav className={styles.nav}>