Skip to content

Commit dc656bc

Browse files
committed
refactor navigation and locales
1 parent e42c09d commit dc656bc

File tree

20 files changed

+58
-54
lines changed

20 files changed

+58
-54
lines changed

src/app/[locale]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { getMessages, getTranslations, unstable_setRequestLocale } from "next-in
44
import { Sora } from "next/font/google";
55
import "./globals.css";
66
import WrapperLayout from "@/components/layout/WrapperLayout";
7-
import { locales } from "@/lib/config";
7+
import { locales } from "@/lib/locales";
88
import { notFound } from "next/navigation";
99
const sora = Sora({ subsets: ["latin"] });
1010

src/app/[locale]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { HomePage } from "@/features/home";
3-
import { locales } from "@/lib/config";
3+
import { locales } from "@/lib/locales";
44
import { unstable_setRequestLocale } from "next-intl/server";
55
import { notFound } from "next/navigation";
66

src/app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { unstable_setRequestLocale } from "next-intl/server";
22
import { redirect } from "@/lib/navigation";
33
import { notFound } from "next/navigation";
4-
import { locales } from "@/lib/config";
4+
import { locales } from "@/lib/locales";
55

66
type Props = {
77
params: {

src/components/common/LocaleToggle/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { useTransition } from "react";
22
import { useLocale } from "next-intl";
33
import { useParams } from "next/navigation";
4-
54
import { usePathname, useRouter } from "@/lib/navigation";
65
import { Locale } from "@/lib/i18n";
76
import { Button } from "@/components/ui/Button";

src/components/common/footer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from "react";
22
import { dataFooter } from "./constants";
3-
import { Link } from "@/lib/navigation";
43
import { Button } from "@/components/ui/Button";
54
import { useTranslations } from "next-intl";
5+
import { Link } from "@/lib/navigation";
66

77
const Footer = () => {
88
const date = new Date();

src/components/common/navbar/NavItem.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/components/common/navbar/constant.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/components/common/sidebar/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import Link from "next/link";
55
import { useTranslations } from "next-intl";
66

77
import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle, SheetTrigger } from "@/components/ui/Sheet";
8-
import NavItem from "../Navbar/NavItem";
8+
import NavLink from "../../../lib/navigation/NavLink";
99
import { ThemeToggle } from "../ThemeToggle";
1010
import LocaleToggle from "../LocaleToggle";
11-
import { LINKS } from "../Navbar/constant";
11+
import { LINKS } from "../../layout/Navbar/constant";
1212

1313
const Sidebar: FC = () => {
1414
const t = useTranslations("Layout");
@@ -29,7 +29,7 @@ const Sidebar: FC = () => {
2929
<SheetDescription>
3030
<nav className="flex flex-col items-center gap-4 mt-2">
3131
{LINKS.map(({ href, id }) => (
32-
<NavItem key={id} href={href} title={t(`navbar.link-${id}`)} onClick={() => setIsOpen(false)} />
32+
<NavLink key={id} href={href} title={t(`navbar.link-${id}`)} onClick={() => setIsOpen(false)} />
3333
))}
3434
<div className="flex gap-2 items-center">
3535
<ThemeToggle />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NavLinkProps } from "../../../lib/navigation/NavLink";
2+
import { ValidPathnames } from "../../../lib/navigation/types";
3+
4+
export const LINKS: NavLinkProps<ValidPathnames>[] = [
5+
{
6+
id: "1",
7+
href: "/about",
8+
},
9+
{
10+
id: "2",
11+
href: "/events",
12+
},
13+
];

src/components/common/navbar/index.tsx renamed to src/components/layout/Navbar/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Link } from "@/lib/navigation";
2-
import NavItem from "./NavItem";
3-
import { ThemeToggle } from "../ThemeToggle";
2+
import NavLink from "../../../lib/navigation/NavLink";
3+
import { ThemeToggle } from "../../common/ThemeToggle";
44
import { useTranslations } from "next-intl";
5-
import LocaleToggle from "../LocaleToggle";
5+
import LocaleToggle from "../../common/LocaleToggle";
66
import { LINKS } from "./constant";
7-
import Sidebar from "../Sidebar";
7+
import Sidebar from "../../common/Sidebar";
88
import AnnouncementLayout from "@/components/layout/AnnouncementLayout";
99

1010
const Navbar = () => {
@@ -21,7 +21,7 @@ const Navbar = () => {
2121

2222
<nav className="lg:flex items-center gap-7 hidden">
2323
{LINKS.map(({ href, id }) => (
24-
<NavItem key={id} href={href} title={t(`navbar.link-${id}`)} />
24+
<NavLink key={id} href={href} title={t(`navbar.link-${id}`)} />
2525
))}
2626
<div className="flex gap-2 items-center">
2727
<ThemeToggle />

0 commit comments

Comments
 (0)