11/* eslint-disable @next/next/no-head-element */
22import React from 'react'
3- import { AppRegistry } from 'react-native'
4- import { useServerInsertedHTML } from 'next/navigation'
53// Layouts
64import RootLayout from './layout'
75// Styles
8- import { getInjectableMediaQueries } from 'aetherspace/styles '
6+ import ServerStylesInjector from './ssr-style-injector '
97// Constants
108import { getBaseUrl } from 'aetherspace/utils/envUtils'
119
@@ -63,37 +61,23 @@ div[data-nextjs-scroll-focus-boundary] {
6361}
6462`
6563
64+ /* --- Metadata -------------------------------------------------------------------------------- */
65+
66+ export const metadata = {
67+ metadataBase : getBaseUrl ( ) ,
68+ }
69+
6670/* --- <Document> ------------------------------------------------------------------------------ */
6771
6872const Document = ( props : { children : React . ReactNode } ) => {
6973 // Props
7074 const { children } = props
7175
72- // -- Serverside Styles --
73-
74- useServerInsertedHTML ( ( ) => {
75- // Get react-native-web styles
76- const Main = ( ) => < RootLayout > { children } </ RootLayout >
77- AppRegistry . registerComponent ( 'Main' , ( ) => Main ) // @ts -ignore
78- const mainApp = AppRegistry . getApplication ( 'Main' )
79- const reactNativeStyleElement = mainApp . getStyleElement ( )
80- // Get aetherspace styles
81- const aetherQueries = getInjectableMediaQueries ( )
82- // Inject styles
83- return (
84- < >
85- { reactNativeStyleElement }
86- < style type = "text/css" dangerouslySetInnerHTML = { { __html : aetherQueries . css } } />
87- </ >
88- )
89- } )
90-
9176 // -- Render --
9277
9378 return (
9479 < html >
9580 < head >
96- < link rel = "canonical" href = { getBaseUrl ( ) } />
9781 { /* - Icons - */ }
9882 < link rel = "icon" href = "/favicon.ico" sizes = "any" />
9983 < link rel = "apple-touch-icon" sizes = "180x180" href = "/apple-touch-icon.png" />
@@ -118,6 +102,7 @@ const Document = (props: { children: React.ReactNode }) => {
118102 />
119103 < meta name = "category" content = "software development" />
120104 { /* - Styling - */ }
105+ < ServerStylesInjector > { children } </ ServerStylesInjector >
121106 < style type = "text/css" dangerouslySetInnerHTML = { { __html : cssReset } } />
122107 < style type = "text/css" dangerouslySetInnerHTML = { { __html : nextReset } } />
123108 { /* - Other - */ }
0 commit comments