Files
mcpedia/apps/web/app/create/page.tsx
T
asepharyana ab3a2dc456
CI / typecheck + build (turbo) (push) Canceled after 0s
feat: Phase 14 — hierarchical folder structure (GitHub-style nested folders)
- Section index pages ([section]/page.tsx): shows folder tree + flat doc list
- Folder index pages: [section]/[...slug]/page.tsx detects folder paths
  and renders subfolder + document listing instead of 404
- Sidebar tree: hierarchical grouping from flat doc slugs, folder icons (📁)
  with proper indentation per depth level
- DocForm v2: parent folder dropdown (populated from existing folders),
  slug input for leaf name, resolved path display
- Core helpers: extractFoldersForSection + classifyPath exported from @mcpedia/core
- CTF writeup reorganized: pwn-100 ret2win moved into pwn/ subfolder
- _index.md folder intro pages for ctf/ and defcon-quals-2024/
- STANDARD_KEYS includes extraFields to avoid badge duplication
2026-08-21 08:37:41 +07:00

35 lines
1.1 KiB
TypeScript

import { listDocuments, extractFoldersForSection } from "@mcpedia/core";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
import DocForm from "@/components/DocForm";
import { WEBHOOK_SECRET } from "@mcpedia/config";
export const dynamic = "force-dynamic";
export default async function CreatePage() {
const cookieStore = await cookies();
const canEdit = cookieStore.get("mcpedia_admin")?.value != null;
if (!canEdit) redirect("/login");
const allDocs = await listDocuments();
// Build folder suggestions per section using the shared helper from core
const sections = ["docs", "writeups", "research", "notes"];
const docPaths = allDocs.map((d) => d.path);
const foldersBySection: Record<string, string[]> = {};
for (const sec of sections) {
foldersBySection[sec] = extractFoldersForSection(docPaths, sec);
}
return (
<div>
<h1 className="text-3xl font-medium text-[#f7f8f8] mb-6">Create Document</h1>
<DocForm
mode="create"
secret={WEBHOOK_SECRET}
existingFolders={foldersBySection}
/>
</div>
);
}