@oberoncms/core
Version:
OberonCMS is a cloud deployable CMS written in typescript based on the Puck visual editor
77 lines (76 loc) • 2.53 kB
JavaScript
import { jsxs, jsx } from "react/jsx-runtime";
import Link from "next/link";
import { buttonVariants, Button } from "@tohuhono/ui/button";
import { ModeToggle } from "@tohuhono/ui/mode-toggle";
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: "\n grid w-full grid-cols-3 items-center bg-sidebar-background p-2\n text-sidebar-foreground\n ",
children: [
/* @__PURE__ */ jsx("div", { className: "flex justify-start gap-1", children }),
/* @__PURE__ */ jsx("div", { className: "flex justify-center", children: path ? /* @__PURE__ */ jsx("a", { href: path, target: "_blank", rel: "noreferrer", 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(ModeToggle, { className: "h-6" }),
/* @__PURE__ */ jsx(
Button,
{
size: "sm",
onClick: async () => {
await signOut();
router.refresh();
},
children: "Sign Out"
}
)
] })
]
}
);
};
export {
Menu
};