refactor: centralize section config — remove all hardcoded section lists
CI / typecheck + build (turbo) (push) Canceled after 0s
CI / typecheck + build (turbo) (push) Canceled after 0s
- New packages/config/src/sections.ts: SECTIONS, SECTIONS_BY_ID, SECTION_IDS (no Node.js built-in imports — safe for client components) - New package entrypoint: @mcpedia/config/sections (exports only sections.ts) - Client components import from @mcpedia/config/sections (no node:fs in bundle) - Server components import from @mcpedia/config (has env/fs, server-only) - Removed hardcoded SECTIONS/SECTION_LABEL/SECTION_ICON from: - [section]/page.tsx (was inline array) - [section]/[...slug]/page.tsx (was hardcoded Record maps) - Sidebar.tsx (was inline array) - layout.tsx (was inline array) - page.tsx (was inline array) - create/page.tsx (was inline array via SECTIONS import) - Added @mcpedia/config/sections entrypoint to package.json exports
This commit is contained in:
1 parent
26a900a030
commit
251a6e9b4d
10 files changed
+202
-203
No files matched your search
+17
-35
@@ -3,6 +3,7 @@ import Link from "next/link";
|
||||
import "./globals.css";
|
||||
import ThemeToggle from "@/components/ThemeToggle";
|
||||
import Sidebar from "@/components/Sidebar";
|
||||
import { SECTIONS } from "@mcpedia/config/sections";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "MCPedia — Knowledge base for humans and AI agents",
|
||||
@@ -10,51 +11,34 @@ export const metadata: Metadata = {
|
||||
"A content-first knowledge base. Humans read the Web UI; AI agents use the MCP server. Both share one Core.",
|
||||
};
|
||||
|
||||
const SECTIONS = [
|
||||
{ id: "docs", label: "Documentation", icon: "📄" },
|
||||
{ id: "writeups", label: "Writeups", icon: "📝" },
|
||||
{ id: "research", label: "Research", icon: "🔬" },
|
||||
{ id: "notes", label: "Notes", icon: "📌" },
|
||||
] as const;
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en" className="h-full scroll-smooth">
|
||||
<body className="min-h-screen bg-[#08090a] text-[#e2e4e7] font-inter">
|
||||
<div hidden>
|
||||
{/* hidden aria-live container for screen readers */}
|
||||
<div id="a11y-live-region" aria-live="polite" aria-atomic="true" />
|
||||
</div>
|
||||
|
||||
<header className="sticky top-0 z-20 border-b border-[#1f2022]">
|
||||
<div className="mx-auto max-w-7xl px-4 h-14 flex items-center justify-between">
|
||||
<Link href="/" className="font-medium text-[#f7f8f8] text-lg">
|
||||
MCPedia
|
||||
</Link>
|
||||
<nav className="flex items-center gap-6 text-sm">
|
||||
<Link
|
||||
href="/docs"
|
||||
className="text-[#d0d6e0] hover:text-[#f7f8f8] transition-colors"
|
||||
>
|
||||
Docs
|
||||
</Link>
|
||||
<Link
|
||||
href="/writeups"
|
||||
className="text-[#d0d6e0] hover:text-[#f7f8f8] transition-colors"
|
||||
>
|
||||
Writeups
|
||||
</Link>
|
||||
<Link
|
||||
href="/research"
|
||||
className="text-[#d0d6e0] hover:text-[#f7f8f8] transition-colors"
|
||||
>
|
||||
Research
|
||||
</Link>
|
||||
<Link
|
||||
href="/notes"
|
||||
className="text-[#d0d6e0] hover:text-[#f7f8f8] transition-colors"
|
||||
>
|
||||
Notes
|
||||
</Link>
|
||||
{SECTIONS.map((s) => (
|
||||
<Link
|
||||
key={s.id}
|
||||
href={`/${s.id}`}
|
||||
className="text-[#d0d6e0] hover:text-[#f7f8f8] transition-colors"
|
||||
>
|
||||
{s.label}
|
||||
</Link>
|
||||
))}
|
||||
<Link
|
||||
href="/search"
|
||||
className="text-[#d0d6e0] hover:text-[#f7f8f8] transition-colors"
|
||||
@@ -74,11 +58,9 @@ export default function RootLayout({
|
||||
|
||||
<div className="mx-auto max-w-7xl">
|
||||
<div className="flex">
|
||||
{/* Sticky sidebar for doc navigation */}
|
||||
<aside className="hidden xl:block w-64 shrink-0 border-r border-[#1f2022]">
|
||||
<Sidebar />
|
||||
</aside>
|
||||
|
||||
<main className="flex-1 min-w-0">
|
||||
<div className="px-8 py-10 max-w-4xl mx-auto lg:max-w-5xl xl:max-w-6xl">
|
||||
{children}
|
||||
|
||||
Reference in new issue
Block a user