cg / hackerproducts
63 files · 5,740 lines · 159.1 KB — Next.js 15, React 19, TypeScript, PostgreSQL, Object Storage, plain CSS.
Quick jump: page.tsxpage.tsxglobals.cssschema.sqlpackage.json
src/app/layout.tsx · 100 lines · 2.8 KB← back to folder
| 1 | import type { Metadata } from "next"; |
| 2 | import Link from "next/link"; |
| 3 | import Script from "next/script"; |
| 4 | import { getCurrentUser, getSiteUrl } from "@/lib/auth"; |
| 5 | import { Header } from "@/components/Header"; |
| 6 | import { MinilyticsIdentify } from "@/components/MinilyticsIdentify"; |
| 7 | import "./globals.css"; |
| 8 | |
| 9 | const siteUrl = getSiteUrl(); |
| 10 | |
| 11 | export const metadata: Metadata = { |
| 12 | metadataBase: new URL(siteUrl), |
| 13 | title: { |
| 14 | default: "hacker products", |
| 15 | template: "%s — hacker products", |
| 16 | }, |
| 17 | description: "A list of products built by hackers.", |
| 18 | alternates: { |
| 19 | canonical: "/", |
| 20 | }, |
| 21 | openGraph: { |
| 22 | title: "hacker products", |
| 23 | description: "A list of products built by hackers.", |
| 24 | url: siteUrl, |
| 25 | siteName: "hacker products", |
| 26 | type: "website", |
| 27 | }, |
| 28 | twitter: { |
| 29 | card: "summary", |
| 30 | title: "hacker products", |
| 31 | description: "A list of products built by hackers.", |
| 32 | }, |
| 33 | }; |
| 34 | |
| 35 | export default async function RootLayout({ |
| 36 | children, |
| 37 | }: { |
| 38 | children: React.ReactNode; |
| 39 | }) { |
| 40 | const user = await getCurrentUser(); |
| 41 | |
| 42 | return ( |
| 43 | <html lang="en"> |
| 44 | <body> |
| 45 | <Script |
| 46 | defer |
| 47 | data-website-id="4z6w1638564z6i3u" |
| 48 | src="https://tinylytics.cg24.workers.dev/js/script.js" |
| 49 | strategy="afterInteractive" |
| 50 | /> |
| 51 | {user && ( |
| 52 | <MinilyticsIdentify |
| 53 | user={{ |
| 54 | id: user.id, |
| 55 | email: user.email, |
| 56 | name: user.name, |
| 57 | username: user.username, |
| 58 | }} |
| 59 | /> |
| 60 | )} |
| 61 | <div className="container"> |
| 62 | <Header /> |
| 63 | <main>{children}</main> |
| 64 | <footer className="site-footer"> |
| 65 | <span> |
| 66 | hacker products <span className="nav-sep">/</span>{" "} |
| 67 | <Link href="/github">source</Link> |
| 68 | </span> |
| 69 | <div className="footer-links"> |
| 70 | {user ? ( |
| 71 | <> |
| 72 | <Link href={`/${user.username}`}>@{user.username}</Link> |
| 73 | <span className="nav-sep">/</span> |
| 74 | <Link href="/settings">settings</Link> |
| 75 | {user.is_admin && ( |
| 76 | <> |
| 77 | <span className="nav-sep">/</span> |
| 78 | <Link href="/admin">moderation</Link> |
| 79 | </> |
| 80 | )} |
| 81 | <span className="nav-sep">/</span> |
| 82 | <form action="/api/auth/logout" method="post" style={{ display: "inline" }}> |
| 83 | <button type="submit" className="link-button"> |
| 84 | sign out |
| 85 | </button> |
| 86 | </form> |
| 87 | </> |
| 88 | ) : ( |
| 89 | <Link href="/login" data-ml-goal="signin_click"> |
| 90 | sign in |
| 91 | </Link> |
| 92 | )} |
| 93 | </div> |
| 94 | </footer> |
| 95 | </div> |
| 96 | </body> |
| 97 | </html> |
| 98 | ); |
| 99 | } |
| 100 |