UNPKG

@oberoncms/core

Version:

OberonCMS is a cloud deployable CMS written in typescript based on the Puck visual editor

71 lines (70 loc) 2.25 kB
import { jsxs, jsx } from "react/jsx-runtime"; import Link from "next/link"; import { buttonVariants, Button } from "@tohuhono/ui/button"; import { ThemeEditorMenu } from "@tohuhono/ui/theme"; import useSWR from "swr"; import { useRouter } from "next/navigation"; import { useOberonActions } from "../hooks/use-oberon.js"; const Menu = ({ title, path, children }) => { const { can, signOut } = useOberonActions(); const router = useRouter(); const { data: showImages } = useSWR("/can/images", () => can("images")); const { data: showUsers } = useSWR("/can/users", () => can("users")); return /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-3 items-center p-2 text-foreground", children: [ /* @__PURE__ */ jsx("div", { className: "flex justify-start gap-1", children }), /* @__PURE__ */ jsx("div", { className: "flex justify-center", children: path ? /* @__PURE__ */ jsx(Link, { href: path, target: "_blank", prefetch: false, children: title || path }) : title }), /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-1", children: [ /* @__PURE__ */ jsx( Link, { className: buttonVariants({ variant: "outline", size: "sm" }), href: "/cms/site", children: "Site" } ), /* @__PURE__ */ jsx( Link, { className: buttonVariants({ variant: "outline", size: "sm" }), href: "/cms/pages", children: "Pages" } ), showImages && /* @__PURE__ */ jsx( Link, { className: buttonVariants({ variant: "outline", size: "sm" }), href: "/cms/images", children: "Images" } ), showUsers && /* @__PURE__ */ jsx( Link, { className: buttonVariants({ variant: "outline", size: "sm" }), href: "/cms/users", children: "Users" } ), /* @__PURE__ */ jsx(ThemeEditorMenu, { className: "h-6" }), /* @__PURE__ */ jsx( Button, { size: "sm", onClick: async () => { await signOut(); router.refresh(); }, children: "Sign Out" } ) ] }) ] }); }; export { Menu };