Skip to content

Commit e570deb

Browse files
authored
Merge pull request #194 from ashert-hsueh/fix/usermenu-login-button
fix: fix login button logic in usermenu
2 parents 54455e1 + f5be5f5 commit e570deb

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

app/components/UserMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function UserMenu({ user, provider }: UserMenuProps) {
3232
</Avatar>
3333
</summary>
3434

35-
<div className="absolute right-0 mt-2 w-60 overflow-hidden rounded-md border border-border bg-popover shadow-lg">
35+
<div className="absolute right-0 mt-2 w-60 overflow-hidden rounded-md border border-border bg-popover shadow-lg z-50">
3636
<div className="border-b border-border bg-muted/40 px-4 py-3">
3737
<p className="text-sm font-medium text-foreground">
3838
{user.name ?? "Signed in"}

app/docs/layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ function pruneEmptyFolders(root: PageTree.Root): PageTree.Root {
6262
return transformRoot(root);
6363
}
6464

65-
export default function Layout({ children }: { children: ReactNode }) {
65+
export default async function Layout({ children }: { children: ReactNode }) {
6666
const tree = pruneEmptyFolders(source.pageTree);
67-
67+
const options = await baseOptions();
6868
return (
6969
<>
7070
{/* Add a class on <html> while in docs to adjust global backgrounds */}
7171
<DocsRouteFlag />
7272
<DocsLayout
7373
tree={tree}
74-
{...baseOptions()}
74+
{...options}
7575
sidebar={{
7676
// Only show top-level items on first load
7777
defaultOpenLevel: 0,

auth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export const { handlers, auth, signIn, signOut } = NextAuth(() => {
2020
if (!databaseUrl) {
2121
console.warn("[auth] DATABASE_URL missing – running without Neon adapter");
2222
}
23-
2423
return {
2524
...authConfig,
2625
providers: [

lib/layout.shared.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
22
import { SignInButton } from "@/app/components/SignInButton";
3-
export function baseOptions(): BaseLayoutProps {
3+
import { UserMenu } from "@/app/components/UserMenu";
4+
import { auth } from "@/auth";
5+
export async function baseOptions(): Promise<BaseLayoutProps> {
6+
const session = await auth();
7+
const user = session?.user;
8+
const provider =
9+
session && "provider" in session
10+
? (session.provider as string | undefined)
11+
: undefined;
412
return {
513
nav: {
614
title: "内卷地狱",
715
children: (
816
<div className="ms-auto flex justify-end">
9-
<SignInButton />
17+
{user ? (
18+
<UserMenu user={user} provider={provider} />
19+
) : (
20+
<SignInButton />
21+
)}
1022
</div>
1123
),
1224
},

0 commit comments

Comments
 (0)