From d855df0d6ed2c76d68a08e742290d17af7067e9c Mon Sep 17 00:00:00 2001 From: Lumither Tao Date: Sat, 25 May 2024 23:20:12 +0800 Subject: [PATCH] feat(navbar) new style, better performance --- app/blog/BlogPostCard.tsx | 2 +- app/blog/page.tsx | 2 +- app/blog/post/[id]/generate.tsx | 6 +- app/blog/post/[id]/page.tsx | 2 +- app/layout.tsx | 10 ++- components/Navbar.tsx | 140 +++++++++++++++++--------------- components/ThemeSwitcher.tsx | 1 + 7 files changed, 90 insertions(+), 73 deletions(-) diff --git a/app/blog/BlogPostCard.tsx b/app/blog/BlogPostCard.tsx index 6edc0c5..498e771 100644 --- a/app/blog/BlogPostCard.tsx +++ b/app/blog/BlogPostCard.tsx @@ -23,7 +23,7 @@ function BlogPostCard({ post }: Props) { return ( -
+
+
    { posts.map((post: JSON, key: React.Key | null | undefined) => (
  • diff --git a/app/blog/post/[id]/generate.tsx b/app/blog/post/[id]/generate.tsx index 98f1bc9..10049a5 100644 --- a/app/blog/post/[id]/generate.tsx +++ b/app/blog/post/[id]/generate.tsx @@ -19,7 +19,7 @@ async function Generate(props: Props) { const response = await axios(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post/${ props.id }`); if (response.status !== 200) { return ( - + Fatal: Failed to load the post. @@ -31,10 +31,10 @@ async function Generate(props: Props) { return (
    - + { (post_data as any)['content'] } diff --git a/app/blog/post/[id]/page.tsx b/app/blog/post/[id]/page.tsx index 28b0ca0..400aedc 100644 --- a/app/blog/post/[id]/page.tsx +++ b/app/blog/post/[id]/page.tsx @@ -4,7 +4,7 @@ import Generate from '@/app/blog/post/[id]/generate'; function BlogReader({ params }: { params: { id: string } }) { return ( -
    +
    ); diff --git a/app/layout.tsx b/app/layout.tsx index 44f1b59..162ac2c 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -17,10 +17,14 @@ export default function RootLayout({ }>) { return ( - + - - { children } +
    + +
    + { children } +
    +
    diff --git a/components/Navbar.tsx b/components/Navbar.tsx index c5d7f9e..056682d 100644 --- a/components/Navbar.tsx +++ b/components/Navbar.tsx @@ -1,33 +1,50 @@ 'use client'; import React, { useEffect, useState } from 'react'; +import { Button, Image } from '@nextui-org/react'; import { - Image, - Navbar as NextUINavbar, - NavbarBrand, - NavbarContent, - NavbarItem, - NavbarMenu, - NavbarMenuItem, - NavbarMenuToggle -} from '@nextui-org/react'; + IoFileTrayFull, + IoHome, + IoInformationCircle, + IoLogoGithub, + IoMail, + IoPencil, + IoPricetags, + IoSearch +} from 'react-icons/io5'; import Link from 'next/link'; -import { usePathname } from 'next/navigation'; import ThemeSwitcher from '@/components/ThemeSwitcher'; - -const entries: { display_name: string; href: string; }[] = [ +const entries: { display_name: string; href: string; icon: React.ReactNode }[] = [ { + icon: , display_name: 'Home', href: '/' }, { + icon: , display_name: 'About', href: '/about' }, { + icon: , display_name: 'Blog', href: '/blog' + }, + { + icon: , + display_name: 'Tags', + href: '/tags' + }, + { + icon: , + display_name: 'Archive', + href: '/Archive' + }, + { + icon: , + display_name: 'Search', + href: '/search' } ]; @@ -48,67 +65,62 @@ function Navbar() { return ( <> - - - - - - - +
    +
    { +
    - -

    { 'Lumither\'s site' }

    -
    - +

    Lumither Tao

    +

    Ad Astra

    - - { +
    + + + + + + +
    - -

    { 'Lumither\'s site' }

    -
    +
    +
      + { + entries.map((meta, key) => ( +
    • + +
    • + )) + } +
    +
    - { entries.map((item, index) => ( - // eslint-disable-next-line react-hooks/rules-of-hooks - - - { item.display_name } - - - )) } -
    - - - +
    +
    - - - - - { entries.map((item, index) => ( - - - { item.display_name } - - - )) } - - +

    { `Toggle Theme` }

    +
    +
    +
    ); } diff --git a/components/ThemeSwitcher.tsx b/components/ThemeSwitcher.tsx index 9db2f10..c416972 100644 --- a/components/ThemeSwitcher.tsx +++ b/components/ThemeSwitcher.tsx @@ -21,6 +21,7 @@ function ThemeSwitcher() {
    } endContent={ } onValueChange={ (isSelected) => {