@oberoncms/core
Version:
OberonCMS is a cloud deployable CMS written in typescript based on the Puck visual editor
66 lines (65 loc) • 2.44 kB
JavaScript
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
import { PreviewFrameTailwind, DynamicTailwind } from "@tohuhono/ui/theme";
import { notFound } from "next/navigation";
import { getTitle } from "./lib/utils.js";
import { useOberonClientContext } from "./hooks/use-oberon.js";
import { Editor } from "./components/editor.js";
import { Preview } from "./components/preview.js";
import { Menu } from "./components/menu.js";
import { Pages } from "./components/pages.js";
import { Images } from "./components/images.js";
import { Users } from "./components/users.js";
import { Site } from "./components/site.js";
import { Login } from "./components/login.js";
import { useOberonImages } from "./hooks/use-oberon-images.js";
const editorConfig = {
root: {
render: ({ children }) => /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(PreviewFrameTailwind, {}),
children
] })
}
};
const previewConfig = {
root: {
render: ({ children }) => /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(DynamicTailwind, {}),
children
] })
}
};
function OberonClient({ config }) {
const { action, data, slug } = useOberonClientContext();
if (action === "login") {
return /* @__PURE__ */ jsx(Login, { ...data });
}
if (action === "edit") {
return /* @__PURE__ */ jsx(Editor, { path: slug, data, config: { ...editorConfig, ...config } });
}
if (action === "preview") {
return /* @__PURE__ */ jsx(
Preview,
{
path: slug,
data,
config: { ...previewConfig, ...config }
}
);
}
if (["users", "images", "pages", "site"].includes("pages")) {
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(Menu, { title: getTitle(action, slug), path: `/cms/${action}` }),
/* @__PURE__ */ jsx("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ jsxs("div", { className: "prose w-full rounded bg-secondary p-3 pb-10 dark:prose-invert lg:prose-lg lg:p-5 lg:pb-10", children: [
action === "users" && /* @__PURE__ */ jsx(Users, { users: data }),
action === "images" && /* @__PURE__ */ jsx(Images, { images: data }),
action === "pages" && /* @__PURE__ */ jsx(Pages, { pages: data }),
action === "site" && /* @__PURE__ */ jsx(Site, { config: data })
] }) })
] });
}
notFound();
}
export {
OberonClient,
useOberonImages
};