Skip to content

Commit 1c4e1cf

Browse files
authored
Merge pull request #18 from String-sg/claude/detail-anchor-nav-empty-sections
fix(detail): hide anchor nav links to empty sections
2 parents 77dfb67 + 4c862dc commit 1c4e1cf

1 file changed

Lines changed: 21 additions & 12 deletions

File tree

app/[slug]/page.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ export default async function ReportDetailPage({ params }: Props) {
2828
const project = PROJECTS.find((p) => p.slug === slug)
2929
if (!project) notFound()
3030

31+
const sections = [
32+
{ id: "overview", label: "Overview" },
33+
...(project.metrics.length > 0 ? [{ id: "metrics", label: "Metrics" }] : []),
34+
...(project.contributors.length > 0 ? [{ id: "contributors", label: "Contributors" }] : []),
35+
...(project.updates.length > 0 ? [{ id: "updates", label: "Updates" }] : []),
36+
]
37+
3138
return (
3239
<div className="min-h-screen bg-background">
3340
{/* Nav */}
@@ -80,18 +87,20 @@ export default async function ReportDetailPage({ params }: Props) {
8087
<DeprecatedAlternative alternative={project.alternative} />
8188
)}
8289

83-
{/* Nav anchors */}
84-
<nav className="flex gap-6 border-b border-border pb-4 mb-10 text-sm font-medium">
85-
{["Overview", "Metrics", "Contributors", "Updates"].map((section) => (
86-
<a
87-
key={section}
88-
href={`#${section.toLowerCase()}`}
89-
className="text-muted-foreground hover:text-foreground transition-colors"
90-
>
91-
{section}
92-
</a>
93-
))}
94-
</nav>
90+
{/* Nav anchors — only render when there's more than just Overview */}
91+
{sections.length > 1 && (
92+
<nav className="flex gap-6 border-b border-border pb-4 mb-10 text-sm font-medium">
93+
{sections.map((section) => (
94+
<a
95+
key={section.id}
96+
href={`#${section.id}`}
97+
className="text-muted-foreground hover:text-foreground transition-colors"
98+
>
99+
{section.label}
100+
</a>
101+
))}
102+
</nav>
103+
)}
95104

96105
{/* Overview */}
97106
<section id="overview" className="mb-12">

0 commit comments

Comments
 (0)