feat: add Discord avatar to share header
This commit is contained in:
+20
-1
@@ -1,15 +1,26 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
|
import { getServerSession } from "next-auth";
|
||||||
import { ArrowLeft, Plus } from "lucide-react";
|
import { ArrowLeft, Plus } from "lucide-react";
|
||||||
|
import { DropdownMenuAvatar } from "@/components/avatar";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ThemeToggle } from "@/components/theme-toggle";
|
import { ThemeToggle } from "@/components/theme-toggle";
|
||||||
|
import { getSessionDiscordId } from "@/lib/auth/auth";
|
||||||
|
import { authOptions } from "@/lib/auth/auth-options";
|
||||||
|
import { getDiscordMemberProfile } from "@/lib/discord/discord";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Share | Erika!",
|
title: "Share | Erika!",
|
||||||
description: "แชร์ข้อความและไฟล์ .txt ผ่านลิงก์สั้น",
|
description: "แชร์ข้อความและไฟล์ .txt ผ่านลิงก์สั้น",
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ShareLayout({ children }: { children: React.ReactNode }) {
|
export default async function ShareLayout({ children }: { children: React.ReactNode }) {
|
||||||
|
const session = await getServerSession(authOptions);
|
||||||
|
const discordId = getSessionDiscordId(session);
|
||||||
|
const profile = discordId
|
||||||
|
? await getDiscordMemberProfile(discordId)
|
||||||
|
: null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background text-foreground">
|
<div className="min-h-screen bg-background text-foreground">
|
||||||
<header className="sticky top-0 z-10 border-b bg-background/90 backdrop-blur">
|
<header className="sticky top-0 z-10 border-b bg-background/90 backdrop-blur">
|
||||||
@@ -31,6 +42,14 @@ export default function ShareLayout({ children }: { children: React.ReactNode })
|
|||||||
สร้างลิงก์
|
สร้างลิงก์
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
{session?.user && (
|
||||||
|
<DropdownMenuAvatar
|
||||||
|
userName={session.user.name ?? ""}
|
||||||
|
userImage={session.user.image ?? ""}
|
||||||
|
profile={profile}
|
||||||
|
showName={false}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<ThemeToggle />
|
<ThemeToggle />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user