feat: Phase 14 — hierarchical folder structure (GitHub-style nested folders)
CI / typecheck + build (turbo) (push) Canceled after 0s
CI / typecheck + build (turbo) (push) Canceled after 0s
- 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
This commit is contained in:
@@ -1,44 +1,34 @@
|
||||
import { WEBHOOK_SECRET } from "@mcpedia/config";
|
||||
import { listDocuments, extractFoldersForSection } from "@mcpedia/core";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import DocForm from "@/components/DocForm";
|
||||
import Link from "next/link";
|
||||
import { WEBHOOK_SECRET } from "@mcpedia/config";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// GET /create — show the document create form.
|
||||
// Requires admin cookie auth.
|
||||
export default async function CreatePage() {
|
||||
const cookieStore = await cookies();
|
||||
const canEdit = cookieStore.get("mcpedia_admin")?.value != null;
|
||||
if (!canEdit) {
|
||||
return (
|
||||
<div className="text-center py-16">
|
||||
<h1 className="text-2xl font-light text-[#f7f8f8] mb-4">
|
||||
Authentication required
|
||||
</h1>
|
||||
<p className="text-[#8a8f98] mb-6">
|
||||
You must be logged in to create documents.
|
||||
</p>
|
||||
<Link
|
||||
href="/login"
|
||||
className="inline-flex items-center gap-2 px-4 py-2 rounded bg-[#5e6ad2] text-white hover:bg-[#7170ff] transition-colors font-medium text-sm"
|
||||
>
|
||||
Login
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
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>
|
||||
<Link
|
||||
href="/"
|
||||
className="text-xs text-[#8a8f98] hover:text-[#d0d6e0] mb-4 inline-block"
|
||||
>
|
||||
← Back
|
||||
</Link>
|
||||
<h1 className="text-2xl font-light text-[#f7f8f8] mb-6">
|
||||
Create Document
|
||||
</h1>
|
||||
<DocForm mode="create" secret={WEBHOOK_SECRET} />
|
||||
<h1 className="text-3xl font-medium text-[#f7f8f8] mb-6">Create Document</h1>
|
||||
<DocForm
|
||||
mode="create"
|
||||
secret={WEBHOOK_SECRET}
|
||||
existingFolders={foldersBySection}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user