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
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { listDocuments, extractFoldersForSection } from "@mcpedia/core";
|
|
import { SECTIONS } from "@mcpedia/config/sections";
|
|
import { WEBHOOK_SECRET } from "@mcpedia/config";
|
|
import { cookies } from "next/headers";
|
|
import { redirect } from "next/navigation";
|
|
import DocForm from "@/components/DocForm";
|
|
|
|
export default async function CreatePage() {
|
|
const cookieStore = await cookies();
|
|
const isAdmin = cookieStore.get("mcpedia_admin")?.value != null;
|
|
if (!isAdmin) redirect("/login");
|
|
|
|
const all = await listDocuments();
|
|
const docPaths = all.map((d) => d.path);
|
|
|
|
return (
|
|
<div>
|
|
<div className="flex items-center gap-2 mb-6">
|
|
<span className="text-2xl">✏️</span>
|
|
<h1 className="text-2xl font-medium text-[#f7f8f8]">Create Document</h1>
|
|
</div>
|
|
|
|
<DocForm
|
|
mode="create"
|
|
secret={WEBHOOK_SECRET}
|
|
existingFolders={Object.fromEntries(
|
|
SECTIONS.map((s) => [s.id, extractFoldersForSection(docPaths, s.id)])
|
|
)}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|