From 62d201f0888120aff53c344fcc6f5f3225e14876 Mon Sep 17 00:00:00 2001 From: enpitsulin Date: Sat, 6 May 2023 21:57:27 +0800 Subject: [PATCH] feat: app router (#492) --- .../{ => components}/EntranceButton.tsx | 0 src/app/(home)/components/Header.tsx | 66 ++++++++++++++++++ src/app/(home)/layout.tsx | 68 ++----------------- src/app/(home)/page.tsx | 15 ++-- src/app/layout.tsx | 43 +++++++----- src/app/providers.tsx | 2 + src/components/common/ConnectButton.tsx | 2 + src/components/common/DarkModeSwitch.tsx | 2 + src/components/common/Logo.tsx | 2 + src/components/ui/Image.tsx | 2 + src/components/ui/UniLink.tsx | 2 + src/{app => lib}/i18n/index.ts | 0 src/{app => lib}/i18n/locales/en/common.json | 0 .../i18n/locales/en/dashboard.json | 0 src/{app => lib}/i18n/locales/en/index.json | 0 src/{app => lib}/i18n/locales/en/site.json | 0 src/{app => lib}/i18n/locales/ja/common.json | 0 .../i18n/locales/ja/dashboard.json | 0 src/{app => lib}/i18n/locales/ja/index.json | 0 src/{app => lib}/i18n/locales/ja/site.json | 0 .../i18n/locales/zh-TW/common.json | 0 .../i18n/locales/zh-TW/dashboard.json | 0 .../i18n/locales/zh-TW/index.json | 0 src/{app => lib}/i18n/locales/zh-TW/site.json | 0 src/{app => lib}/i18n/locales/zh/common.json | 0 .../i18n/locales/zh/dashboard.json | 0 src/{app => lib}/i18n/locales/zh/index.json | 0 src/{app => lib}/i18n/locales/zh/site.json | 0 src/{app => lib}/i18n/settings.ts | 0 29 files changed, 118 insertions(+), 86 deletions(-) rename src/app/(home)/{ => components}/EntranceButton.tsx (100%) create mode 100644 src/app/(home)/components/Header.tsx rename src/{app => lib}/i18n/index.ts (100%) rename src/{app => lib}/i18n/locales/en/common.json (100%) rename src/{app => lib}/i18n/locales/en/dashboard.json (100%) rename src/{app => lib}/i18n/locales/en/index.json (100%) rename src/{app => lib}/i18n/locales/en/site.json (100%) rename src/{app => lib}/i18n/locales/ja/common.json (100%) rename src/{app => lib}/i18n/locales/ja/dashboard.json (100%) rename src/{app => lib}/i18n/locales/ja/index.json (100%) rename src/{app => lib}/i18n/locales/ja/site.json (100%) rename src/{app => lib}/i18n/locales/zh-TW/common.json (100%) rename src/{app => lib}/i18n/locales/zh-TW/dashboard.json (100%) rename src/{app => lib}/i18n/locales/zh-TW/index.json (100%) rename src/{app => lib}/i18n/locales/zh-TW/site.json (100%) rename src/{app => lib}/i18n/locales/zh/common.json (100%) rename src/{app => lib}/i18n/locales/zh/dashboard.json (100%) rename src/{app => lib}/i18n/locales/zh/index.json (100%) rename src/{app => lib}/i18n/locales/zh/site.json (100%) rename src/{app => lib}/i18n/settings.ts (100%) diff --git a/src/app/(home)/EntranceButton.tsx b/src/app/(home)/components/EntranceButton.tsx similarity index 100% rename from src/app/(home)/EntranceButton.tsx rename to src/app/(home)/components/EntranceButton.tsx diff --git a/src/app/(home)/components/Header.tsx b/src/app/(home)/components/Header.tsx new file mode 100644 index 00000000..62687764 --- /dev/null +++ b/src/app/(home)/components/Header.tsx @@ -0,0 +1,66 @@ +"use client" + +import { usePathname } from "next/navigation" +import { useTranslation } from "react-i18next" + +import { ConnectButton } from "~/components/common/ConnectButton" +import { Logo } from "~/components/common/Logo" +import { Image } from "~/components/ui/Image" +import { UniLink } from "~/components/ui/UniLink" +import { GITHUB_LINK } from "~/lib/env" +import { cn } from "~/lib/utils" + +const tabs = [ + { + name: "Home", + link: "/", + }, + { + name: "Activities", + link: "/activities", + }, + { + name: ( + github stars + ), + link: GITHUB_LINK, + }, +] + +export function Header() { + const { t } = useTranslation("index") + const pathname = usePathname() + return ( +
+
+ +
+ +
+ xLog +
+
+ {tabs?.map((tab, index) => ( + + ))} + +
+
+
+ ) +} diff --git a/src/app/(home)/layout.tsx b/src/app/(home)/layout.tsx index ec790ddb..e47e26af 100644 --- a/src/app/(home)/layout.tsx +++ b/src/app/(home)/layout.tsx @@ -1,72 +1,18 @@ -import { useTranslation } from "next-i18next" -import { usePathname } from "next/navigation" - -import { ConnectButton } from "~/components/common/ConnectButton" import { DarkModeSwitch } from "~/components/common/DarkModeSwitch" -import { Logo } from "~/components/common/Logo" -import { Image } from "~/components/ui/Image" import { UniLink } from "~/components/ui/UniLink" import { APP_NAME, DISCORD_LINK, GITHUB_LINK, TWITTER_LINK } from "~/lib/env" import { getSiteLink } from "~/lib/helpers" -import { cn } from "~/lib/utils" -const tabs = [ - { - name: "Home", - link: "/", - }, - { - name: "Activities", - link: "/activities", - }, - { - name: ( - github stars - ), - link: GITHUB_LINK, - }, -] - -export function HomeLayout({ children }: { children?: React.ReactNode }) { - const { t } = useTranslation("index") - const pathname = usePathname() +import { Header } from "./components/Header" +export default async function HomeLayout({ + children, +}: { + children?: React.ReactNode +}) { return ( <> -
-
- -
- -
- xLog -
-
- {tabs?.map((tab, index) => ( - - ))} - -
-
-
+
{children}