auth
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import "~/styles/globals.css";
|
||||
|
||||
import Link from "next/link";
|
||||
import type { Metadata } from "next";
|
||||
import { Geist } from "next/font/google";
|
||||
|
||||
import { ClerkProvider, SignedIn, SignedOut, SignUpButton, UserButton } from "@clerk/nextjs";
|
||||
import { auth } from "@clerk/nextjs/server";
|
||||
import { env } from "~/env";
|
||||
export const metadata: Metadata = {
|
||||
title: "Create T3 App",
|
||||
description: "Generated by create-t3-app",
|
||||
icons: [{ rel: "icon", url: "/favicon.ico" }],
|
||||
title: "Gregor Lohaus",
|
||||
description: "My Personal Website",
|
||||
icons: [{ rel: "icon", url: "/GLIcon.svg" }],
|
||||
};
|
||||
|
||||
const geist = Geist({
|
||||
@@ -14,13 +17,32 @@ const geist = Geist({
|
||||
variable: "--font-geist-sans",
|
||||
});
|
||||
|
||||
const TopNav = () => {
|
||||
const AdminWrap = async ({children,}: Readonly<{ children: React.ReactNode }>) => {
|
||||
const userid = (await auth()).userId
|
||||
const isAdmin = (userid == env.ADMIN_USER_CLERK_ID)
|
||||
if (isAdmin) {
|
||||
return <>{children}</>
|
||||
}
|
||||
return (<></>)
|
||||
}
|
||||
|
||||
const TopNav = async () => {
|
||||
return (
|
||||
<nav className="flex w-full border-b p-4 gap-5 bg-black text-white border-white">
|
||||
<div> Blog </div>
|
||||
<div> CV </div>
|
||||
<div> Projects </div>
|
||||
<div> Fun </div>
|
||||
<nav className="flex flex-wrap items-center w-full border-b px-5 py-5 gap-5 bg-black text-white border-white">
|
||||
<Link className="h-fit" href={"/blog"}> Blog </Link>
|
||||
<Link className="h-fit" href={"/cv"}> CV </Link>
|
||||
<Link className="h-fit" href={"/projects"}> Projects </Link>
|
||||
<Link className="h-fit" href={"/fun"}> Fun </Link>
|
||||
<div className="ml-auto"/>
|
||||
<AdminWrap><Link className="h-fit" href={"/admin"}> Admin </Link></AdminWrap>
|
||||
<div className="h-fit flex">
|
||||
<SignedIn>
|
||||
<UserButton/>
|
||||
</SignedIn>
|
||||
<SignedOut>
|
||||
<SignUpButton/>
|
||||
</SignedOut>
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
@@ -29,11 +51,13 @@ export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{ children: React.ReactNode }>) {
|
||||
return (
|
||||
<html lang="en" className={`${geist.variable}`}>
|
||||
<body className="flex flex-col gap-2 bg-black text-white">
|
||||
<TopNav/>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
<ClerkProvider>
|
||||
<html lang="en" className={`${geist.variable}`}>
|
||||
<body className="flex flex-col gap-2 bg-black text-white">
|
||||
<TopNav/>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
</ClerkProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user