layout.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import "@/styles/globals.css";
  2. import type { Metadata, Viewport } from "next";
  3. import { Analytics } from "@vercel/analytics/next";
  4. import { ThemeProvider } from "next-themes";
  5. import { Backdrop } from "@/components/backdrop/backdrop";
  6. import { CursorLens } from "@/components/glass/cursor-lens";
  7. import { SiteNav } from "@/components/nav/site-nav";
  8. import { SiteFooter } from "@/components/site-footer";
  9. import { UpdateOnReturn } from "@/components/update-on-return";
  10. import { FontLoader } from "@/components/font-loader";
  11. import { deferredFaces, fontDisplay, fontName, fontText } from "@/config/fonts";
  12. import { siteConfig } from "@/config/site";
  13. export const metadata: Metadata = {
  14. metadataBase: new URL(siteConfig.url),
  15. title: {
  16. default: siteConfig.name,
  17. template: `%s - ${siteConfig.name}`,
  18. },
  19. description: siteConfig.description,
  20. keywords: siteConfig.keywords,
  21. authors: [{ name: siteConfig.author, url: siteConfig.url }],
  22. creator: siteConfig.author,
  23. alternates: {
  24. canonical: "/",
  25. },
  26. openGraph: {
  27. type: "website",
  28. locale: "en_US",
  29. url: siteConfig.url,
  30. siteName: siteConfig.name,
  31. title: siteConfig.name,
  32. description: siteConfig.description,
  33. },
  34. twitter: {
  35. card: "summary_large_image",
  36. title: siteConfig.name,
  37. description: siteConfig.description,
  38. },
  39. robots: {
  40. index: true,
  41. follow: true,
  42. googleBot: {
  43. index: true,
  44. follow: true,
  45. "max-video-preview": -1,
  46. "max-image-preview": "large",
  47. "max-snippet": -1,
  48. },
  49. },
  50. icons: {
  51. icon: "/favicon.ico",
  52. },
  53. };
  54. export const viewport: Viewport = {
  55. themeColor: [
  56. { media: "(prefers-color-scheme: light)", color: "#f6f2f2" },
  57. { media: "(prefers-color-scheme: dark)", color: "#0b0f11" },
  58. ],
  59. };
  60. const jsonLd = {
  61. "@context": "https://schema.org",
  62. "@graph": [
  63. {
  64. "@type": "WebSite",
  65. "@id": `${siteConfig.url}/#website`,
  66. url: siteConfig.url,
  67. name: siteConfig.name,
  68. description: siteConfig.description,
  69. inLanguage: "en-US",
  70. },
  71. {
  72. "@type": "Person",
  73. "@id": `${siteConfig.url}/#person`,
  74. name: "Eric Wu",
  75. alternateName: "Chengxiang Wu",
  76. url: siteConfig.url,
  77. jobTitle: "Software Development Engineer II",
  78. worksFor: {
  79. "@type": "Organization",
  80. name: "Amazon Web Services",
  81. },
  82. alumniOf: [
  83. {
  84. "@type": "CollegeOrUniversity",
  85. name: "University of California, Los Angeles",
  86. },
  87. {
  88. "@type": "CollegeOrUniversity",
  89. name: "Purdue University",
  90. },
  91. ],
  92. sameAs: [siteConfig.links.github, siteConfig.links.linkedin],
  93. },
  94. ],
  95. };
  96. export default function RootLayout({
  97. children,
  98. }: {
  99. children: React.ReactNode;
  100. }) {
  101. return (
  102. <html
  103. suppressHydrationWarning
  104. className={`${fontText.variable} ${fontDisplay.variable} ${fontName.variable}`}
  105. lang="en"
  106. >
  107. <head>
  108. {/* Returning visitors have the display face cached: use it from the first frame. */}
  109. <script
  110. dangerouslySetInnerHTML={{
  111. __html:
  112. 'try{localStorage.getItem("ff")&&document.documentElement.classList.add("ff")}catch(e){}',
  113. }}
  114. />
  115. <script
  116. dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
  117. type="application/ld+json"
  118. />
  119. </head>
  120. <body>
  121. <ThemeProvider
  122. disableTransitionOnChange
  123. enableSystem
  124. attribute="class"
  125. defaultTheme="system"
  126. >
  127. <a
  128. className="sr-only fixed top-3 left-3 z-[80] rounded-full bg-ink px-4 py-2 text-bg focus:not-sr-only"
  129. href="#main"
  130. >
  131. Skip to content
  132. </a>
  133. <Backdrop />
  134. <SiteNav />
  135. <main
  136. className="relative z-10 mx-auto w-full max-w-[1240px] grow px-3 pt-6 pb-6 sm:px-6 sm:pt-24 sm:pb-9"
  137. id="main"
  138. >
  139. {children}
  140. </main>
  141. <SiteFooter />
  142. <CursorLens />
  143. <UpdateOnReturn />
  144. </ThemeProvider>
  145. <FontLoader faces={deferredFaces} />
  146. <Analytics />
  147. </body>
  148. </html>
  149. );
  150. }