CI / typecheck + build (turbo) (push) Canceled after 0s
- Migrate document fetching and CRUD to be PostgreSQL-authoritative - Remove static section enums and add dynamic listSections query - Support custom sections and metadata across API, MCP, and Web UI - Add /api/sections endpoint and update Header, Sidebar, and Forms - Remove obsolete phase planning docs and modernize README/AGENTS
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import Link from "next/link";
|
|
import { listDocuments, extractFoldersForSection, listSections } from "@mcpedia/core";
|
|
import { WEBHOOK_SECRET } from "@mcpedia/config";
|
|
import { cookies } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
import DocForm from "@/components/DocForm";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export default async function CreatePage() {
|
|
const cookieStore = await cookies();
|
|
const isAdmin = cookieStore.get("mcpedia_admin")?.value != null;
|
|
if (!isAdmin) redirect("/login");
|
|
|
|
const [all, sections] = await Promise.all([
|
|
listDocuments(),
|
|
listSections(),
|
|
]);
|
|
|
|
const docSlugs = all.map((d) => d.slug);
|
|
const sectionIds = Array.from(new Set([...sections.map((s) => s.id), ...all.map((d) => d.section)]));
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
{/* Breadcrumb */}
|
|
<nav className="flex items-center gap-2 text-xs text-[var(--text-dim)]">
|
|
<Link href="/" className="hover:text-[var(--text-primary)] transition-colors">
|
|
MCPedia
|
|
</Link>
|
|
<span>/</span>
|
|
<span className="text-[var(--text-muted)] font-medium">Create Document</span>
|
|
</nav>
|
|
|
|
{/* Header */}
|
|
<div className="flex items-center justify-between pb-4 border-b border-[var(--border-color)]">
|
|
<div className="flex items-center gap-3">
|
|
<div className="w-10 h-10 rounded-lg bg-[#5e6ad2]/15 border border-[#5e6ad2]/30 flex items-center justify-center text-xl text-[#5e6ad2] dark:text-[#7170ff]">
|
|
✏️
|
|
</div>
|
|
<div>
|
|
<h1 className="text-2xl font-bold text-[var(--text-primary)] tracking-tight">Create Document</h1>
|
|
<p className="text-xs text-[var(--text-muted)] mt-0.5">
|
|
Writes directly to PostgreSQL, records revision history, and computes vector embeddings.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<DocForm
|
|
mode="create"
|
|
secret={WEBHOOK_SECRET}
|
|
existingSections={sectionIds}
|
|
existingFolders={Object.fromEntries(
|
|
sectionIds.map((sid) => [sid, extractFoldersForSection(docSlugs, sid)])
|
|
)}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|