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 committed 2026-08-21 10:29:35 +07:00
1 parent 26a900a030
commit 251a6e9b4d
10 files changed
+202 -203

No files matched your search

+1 -14
View File
@@ -1,5 +1,6 @@
import Link from "next/link";
import { listDocuments } from "@mcpedia/core";
import { SECTIONS } from "@mcpedia/config/sections";
export const dynamic = "force-dynamic";
@@ -12,18 +13,6 @@ interface DocMeta {
path: string;
}
const SECTIONS: { id: string; label: string; icon: string; desc: string }[] = [
{
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." },
];
/**
* Build a hierarchical folder tree from a flat list of documents.
* Each node is either a folder (has children) or a leaf doc.
@@ -68,8 +57,6 @@ function buildFolderTree(docs: DocMeta[], section: string): TreeNode[] {
if (isLeaf) {
node.doc = doc;
node.docCount = 1;
} else {
// This is a folder — count will be accumulated below
}
current = node.children;
}