diff --git a/components/header.tsx b/components/header.tsx
index 05b476b..31debf8 100644
--- a/components/header.tsx
+++ b/components/header.tsx
@@ -158,17 +158,7 @@ export default function Header(props: { fixed?: boolean }) {
{
- e.preventDefault();
- e.stopPropagation();
- if (path === item.page) {
- document
- .getElementById(item.id)
- ?.scrollIntoView({ behavior: "smooth" });
- } else {
- router.push(item.page + "#" + item.id);
- }
- }}
+ scroll={false}
>
{item.content}
diff --git a/pages/index.tsx b/pages/index.tsx
index c567e04..e45e773 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,5 +1,5 @@
/* eslint-disable @next/next/no-img-element */
-import { useState } from "react";
+import { useEffect, useState } from "react";
import {
ArrowPathIcon,
ChevronRightIcon,
@@ -16,6 +16,7 @@ import Link from "next/link";
import CommitLayout from "@/components/Commit/CommitLayout";
import Header from "@/components/header";
import Footer from "@/components/Footer";
+import { useRouter } from "next/router";
const primaryFeatures = [
{
@@ -147,6 +148,17 @@ type Banner = {
href: string;
};
export default function Home() {
+ const router = useRouter();
+
+ if (router.asPath.includes("#")) {
+ const hash = router.asPath.split("#")[1];
+ setTimeout(() => {
+ const targetElement = document.getElementById(hash);
+ if (targetElement) {
+ targetElement.scrollIntoView({ behavior: "smooth" });
+ }
+ }, 500);
+ }
const [banner, setBanner] = useState(null);