layout.js 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. import { Providers } from './providers'
  2. import { resolveServerLangCode } from '../lib/resolve-lang'
  3. import { fontVars } from 'app/customization/design/fonts/fonts-web'
  4. import { getCornerSmoothingHtmlProps } from 'app/design/corner-smoothing'
  5. import { appSetting } from 'app/config'
  6. import { resources } from 'app/customization/translation'
  7. import 'app/design/styles/global.css'
  8. import 'app/customization/design/styles/global.css'
  9. import 'app/design/styles/global.web.css'
  10. import 'app/customization/design/styles/global.web.css'
  11. export default async function RootLayout({ children }) {
  12. const langCode = await resolveServerLangCode()
  13. const cornerSmooth = getCornerSmoothingHtmlProps()
  14. const htmlClassName = [fontVars, cornerSmooth.className].filter(Boolean).join(' ')
  15. // Only this page's language (+ the `en` fallback) goes to the client; the
  16. // rest load on demand (app/lib/i18n-resources). Server component, so the
  17. // full `resources` never reach the client bundle from here.
  18. const initialResources = { en: resources.en, [langCode]: resources[langCode] }
  19. return (
  20. <html
  21. lang={langCode}
  22. className={htmlClassName}
  23. style={cornerSmooth.style}
  24. suppressHydrationWarning
  25. >
  26. <body className={appSetting('layout', 'body')}>
  27. <Providers initialLang={langCode} initialResources={initialResources} onVercel={!!process.env.VERCEL}>{children}</Providers>
  28. </body>
  29. </html>
  30. )
  31. }