|
| 1 | +import type {Metadata, Viewport} from 'next'; |
1 | 2 | import {SharedRootBody, SharedRootHead} from '../components/_/root-layout'; |
2 | 3 | import {siteConfig} from '../siteConfig'; |
| 4 | +import {preload} from 'react-dom'; |
| 5 | + |
| 6 | +import '@docsearch/css'; |
| 7 | +import '../styles/algolia.css'; |
| 8 | +import '../styles/index.css'; |
| 9 | +import '../styles/sandpack.css'; |
3 | 10 |
|
4 | 11 | export default function RootLayout({children}: React.PropsWithChildren) { |
| 12 | + [ |
| 13 | + 'https://react.dev/fonts/Source-Code-Pro-Regular.woff2', |
| 14 | + 'https://react.dev/fonts/Source-Code-Pro-Bold.woff2', |
| 15 | + 'https://react.dev/fonts/Optimistic_Display_W_Md.woff2', |
| 16 | + 'https://react.dev/fonts/Optimistic_Display_W_SBd.woff2', |
| 17 | + 'https://react.dev/fonts/Optimistic_Display_W_Bd.woff2', |
| 18 | + 'https://react.dev/fonts/Optimistic_Text_W_Md.woff2', |
| 19 | + 'https://react.dev/fonts/Optimistic_Text_W_Bd.woff2', |
| 20 | + 'https://react.dev/fonts/Optimistic_Text_W_Rg.woff2', |
| 21 | + 'https://react.dev/fonts/Optimistic_Text_W_It.woff2', |
| 22 | + ].forEach((href) => { |
| 23 | + preload(href, {as: 'font', type: 'font/woff2', crossOrigin: 'anonymous'}); |
| 24 | + }); |
| 25 | + |
5 | 26 | return ( |
6 | | - <html lang={siteConfig.languageCode} dir={siteConfig.isRTL ? 'rtl' : 'ltr'}> |
| 27 | + <html |
| 28 | + lang={siteConfig.languageCode} |
| 29 | + dir={siteConfig.isRTL ? 'rtl' : 'ltr'} |
| 30 | + suppressHydrationWarning> |
7 | 31 | <head> |
8 | 32 | <SharedRootHead /> |
9 | 33 | </head> |
10 | 34 | <SharedRootBody>{children}</SharedRootBody> |
11 | 35 | </html> |
12 | 36 | ); |
13 | 37 | } |
| 38 | + |
| 39 | +export const viewport: Viewport = { |
| 40 | + width: 'device-width', |
| 41 | + initialScale: 1, |
| 42 | +}; |
| 43 | + |
| 44 | +export const metadata: Metadata = { |
| 45 | + metadataBase: new URL('https://' + getDomain(siteConfig.languageCode)), |
| 46 | + alternates: { |
| 47 | + canonical: './', |
| 48 | + }, |
| 49 | + openGraph: { |
| 50 | + type: 'website', |
| 51 | + url: './', |
| 52 | + images: ['/images/og-default.png'], |
| 53 | + }, |
| 54 | + twitter: { |
| 55 | + card: 'summary_large_image', |
| 56 | + site: '@reactjs', |
| 57 | + creator: '@reactjs', |
| 58 | + images: ['/images/og-default.png'], |
| 59 | + }, |
| 60 | + facebook: { |
| 61 | + appId: '623268441017527', |
| 62 | + }, |
| 63 | +}; |
| 64 | + |
| 65 | +function getDomain(languageCode: string): string { |
| 66 | + const subdomain = languageCode === 'en' ? '' : languageCode + '.'; |
| 67 | + return subdomain + 'react.dev'; |
| 68 | +} |
0 commit comments