refactor: centralize section config — remove all hardcoded section lists
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:
asepharyana
2026-08-21 10:29:35 +07:00
parent 26a900a030
commit 251a6e9b4d
10 changed files with 202 additions and 203 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* Section registry — defines all content sections for the UI.
* This file is intentionally free of Node.js built-in imports (no fs/path)
* so it can be safely imported by client components.
*
* Adding a new section is as simple as adding an entry here + creating a
* `content/<id>/` directory with markdown files. No UI code changes needed.
*/
export interface SectionConfig {
id: string;
label: string;
icon: string;
desc: string;
}
export const SECTIONS: SectionConfig[] = [
{
id: "docs",
label: "Documentation",
icon: "📄",
desc: "Setup guides, API references, and protocol specs.",
},
{
id: "writeups",
label: "Writeups",
icon: "📝",
desc: "Post-mortems, debugging stories, and case studies.",
},
{
id: "research",
label: "Research",
icon: "🔬",
desc: "Deep-dive analysis, architecture notes, and experiments.",
},
{
id: "notes",
label: "Notes",
icon: "📌",
desc: "Quick references, patterns, and gotchas.",
},
];
export const SECTIONS_BY_ID = new Map(SECTIONS.map((s) => [s.id, s]));
export const SECTION_IDS = SECTIONS.map((s) => s.id);