From b7bf76977a674b08043366598a985c1aa1e6088d Mon Sep 17 00:00:00 2001 From: albugowy15 Date: Sun, 22 Jan 2023 12:53:37 +0700 Subject: [PATCH 1/4] add social media in navbar --- package.json | 1 + public/sitemap.xml | 30 +-- src/components/layout/partials/Navbar.tsx | 195 +++++++++++------ src/modules/blog/pages/BlogDetail.tsx | 60 +++-- src/styles/globals.scss | 88 ++++---- src/utils/hooks/useHeadingObserver.ts | 33 +++ src/utils/hooks/useScrollHeadings.ts | 53 +++++ src/utils/hooks/useScrollSpy.ts | 47 ++++ yarn.lock | 254 ++++++++++++---------- 9 files changed, 490 insertions(+), 271 deletions(-) create mode 100644 src/utils/hooks/useHeadingObserver.ts create mode 100644 src/utils/hooks/useScrollHeadings.ts create mode 100644 src/utils/hooks/useScrollSpy.ts diff --git a/package.json b/package.json index 6d2dd30..2d43d7e 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "react-icons": "^4.4.0", + "react-use-scrollspy": "^3.1.1", "reading-time": "^1.5.0", "rehype": "^12.0.1", "rehype-code-titles": "^1.1.0", diff --git a/public/sitemap.xml b/public/sitemap.xml index 498569c..520d72a 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -1,18 +1,18 @@ -https://www.bughowi.com2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/about2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/projects2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog/build-react-form-with-react-hook-form-and-yup2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog/create-blog-with-mdx-contentlayer2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog/nextjs-key-features2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog/simple-toc-in-mdx2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog/typescript-fundamentals2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/blog/usecontext-and-redux2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/projects/bughowi-com2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/projects/jamjiwa2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/projects/jelata2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/projects/netflix-clone2023-01-19T18:02:39.511Zdaily0.7 -https://www.bughowi.com/projects/nextjs-blog2023-01-19T18:02:39.511Zdaily0.7 +https://www.bughowi.com2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/about2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/projects2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog/build-react-form-with-react-hook-form-and-yup2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog/create-blog-with-mdx-contentlayer2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog/nextjs-key-features2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog/simple-toc-in-mdx2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog/typescript-fundamentals2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/blog/usecontext-and-redux2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/projects/bughowi-com2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/projects/jamjiwa2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/projects/jelata2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/projects/netflix-clone2023-01-21T13:02:41.508Zdaily0.7 +https://www.bughowi.com/projects/nextjs-blog2023-01-21T13:02:41.508Zdaily0.7 \ No newline at end of file diff --git a/src/components/layout/partials/Navbar.tsx b/src/components/layout/partials/Navbar.tsx index 960b0c5..4421809 100644 --- a/src/components/layout/partials/Navbar.tsx +++ b/src/components/layout/partials/Navbar.tsx @@ -3,36 +3,40 @@ import { useEffect, useState } from "react"; import { useRouter } from "next/router"; import Image from "next/image"; import pp from "@assets/profile-picture.png"; +import clsx from "clsx"; +import { BsGithub, BsLinkedin, BsTwitter } from "react-icons/bs"; +import { AiFillCaretDown } from "react-icons/ai"; const Navbar = () => { const [onTop, setOnTop] = useState(true); + const [showDropdown, setShowDropdown] = useState(false); const router = useRouter(); function handleScroll() { if (onTop !== (window.scrollY === 0)) { - setOnTop(window.scrollY === 0); + setOnTop(window.scrollY == 0); } + console.log(onTop); } useEffect(() => { window.addEventListener("scroll", handleScroll); + console.log(onTop); return () => { window.removeEventListener("scroll", handleScroll); }; }); return ( -