2026-07-19 00:29:30 +08:00
import "./styles.css" ;
import Link from "next/link" ;
import { getSession } from "@/lib/auth" ;
2026-07-19 03:16:18 +08:00
import { db } from "@/lib/db" ;
export const metadata = { title : "Mebbling" , description : "聚合朋友公開筆記的 Memos Hub" , alternates : { types : { "application/rss+xml" : [{ url : "/rss.xml" , title : "Mebbling RSS" }], "application/atom+xml" : [{ url : "/atom.xml" , title : "Mebbling Atom" }] } }, openGraph : { title : "Mebbling" , description : "聚合朋友公開筆記的 Memos Hub" , type : "website" } };
2026-07-19 00:29:30 +08:00
export default async function RootLayout ({ children } : { children : React.ReactNode }) {
const user = await getSession ();
2026-07-19 03:16:18 +08:00
const unread = user ? Number (( db . prepare ( "SELECT count(*) count FROM notifications WHERE user_id=? AND read_at IS NULL" ). get ( user . id ) as { count : number }). count ) : 0 ;
return < html lang = "zh-Hant" >< body >< header >< Link href = "/" className = "brand" > Mebbling </ Link >< nav >< Link href = "/" > 探索 </ Link >{ user ? <>< Link href = "/reading" > 閱讀清單 </ Link >< Link href = "/notifications" > 通知 { unread ? ` ( ${ unread } )` : "" }</ Link >< Link href = "/dashboard" > 控制台 </ Link >< Link href = "/account" > 帳號 </ Link >{ user . role === "admin" && < Link href = "/admin" > 管理 </ Link >}< form action = "/api/auth/logout" method = "post" >< button > 登出 </ button ></ form ></> : <>< Link href = "/login" > 登入 </ Link >< Link href = "/register" > 註冊 </ Link ></>}</ nav ></ header >< main >{ children }</ main ></ body ></ html >;
2026-07-19 00:29:30 +08:00
}