layout.tsx 4.0 KB

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