Skip to content

Commit cf6997d

Browse files
committed
fix(nav): 非首页点击 Header 也能回主页
- BrandMark 外层包 <Link href="/">,点 logo 回首页 - Header 三个锚点从 #features 改为 /#features 等绝对路径, 从 /rank 或任意子页点导航能跳回主页对应区块 方案 F(最小修复),比引入 Header 全站 layout 或新组件成本更低。
1 parent 967b07b commit cf6997d

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

app/components/BrandMark.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* @param {boolean} priority - 是否优先加载
1313
*/
1414
import Image from "next/image";
15+
import Link from "next/link";
1516
import { cn } from "@/lib/utils";
1617

1718
export const BRAND_NAME = "Involution Hell";
@@ -38,7 +39,7 @@ export function BrandMark({
3839
const width = Math.round(imageSize * BRAND_LOGO_ASPECT_RATIO);
3940

4041
return (
41-
<div className={cn("flex items-center gap-2", className)}>
42+
<Link href="/" className={cn("flex items-center gap-2", className)}>
4243
<div className="relative">
4344
<Image
4445
src={BRAND_LOGO_LIGHT_SRC}
@@ -65,6 +66,6 @@ export function BrandMark({
6566
>
6667
{BRAND_NAME}
6768
</span>
68-
</div>
69+
</Link>
6970
);
7071
}

app/components/Header.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ export function Header() {
3131
<div className="flex items-center justify-between h-10">
3232
<nav className="hidden md:flex items-center gap-8 font-sans text-xs font-bold uppercase tracking-widest text-[var(--foreground)]">
3333
<a
34-
href="#features"
34+
href="/"
35+
className="hover:text-[#CC0000] transition-colors"
36+
data-umami-event="navigation_click"
37+
data-umami-event-region="header"
38+
data-umami-event-label="home"
39+
>
40+
首页
41+
</a>
42+
<a
43+
href="/#features"
3544
className="hover:text-[#CC0000] transition-colors"
3645
data-umami-event="navigation_click"
3746
data-umami-event-region="header"
@@ -40,7 +49,7 @@ export function Header() {
4049
特点
4150
</a>
4251
<a
43-
href="#community"
52+
href="/#community"
4453
className="hover:text-[#CC0000] transition-colors"
4554
data-umami-event="navigation_click"
4655
data-umami-event-region="header"
@@ -49,7 +58,7 @@ export function Header() {
4958
社区
5059
</a>
5160
<a
52-
href="#contact"
61+
href="/#contact"
5362
className="hover:text-[#CC0000] transition-colors"
5463
data-umami-event="navigation_click"
5564
data-umami-event-region="header"

0 commit comments

Comments
 (0)