2023-02-17 09:21:02 +00:00
|
|
|
import { App } from '../components/App'
|
|
|
|
|
|
|
|
import { hydrate } from 'solid-js/web'
|
|
|
|
import type { PageContextBuiltInClient } from 'vite-plugin-ssr/client/router'
|
|
|
|
import type { PageContext } from './types'
|
|
|
|
import { MetaProvider } from '@solidjs/meta'
|
2023-05-01 18:32:32 +00:00
|
|
|
import { use as useI18next, init as initI18next } from 'i18next'
|
2023-02-17 09:21:02 +00:00
|
|
|
import HttpApi from 'i18next-http-backend'
|
|
|
|
|
|
|
|
let layoutReady = false
|
|
|
|
|
|
|
|
export const render = async (pageContext: PageContextBuiltInClient & PageContext) => {
|
|
|
|
const { lng, pageProps } = pageContext
|
|
|
|
|
2023-05-01 18:32:32 +00:00
|
|
|
useI18next(HttpApi)
|
|
|
|
await initI18next({
|
2023-02-17 09:21:02 +00:00
|
|
|
// debug: true,
|
|
|
|
supportedLngs: ['ru', 'en'],
|
|
|
|
fallbackLng: lng,
|
|
|
|
lng,
|
|
|
|
load: 'languageOnly'
|
|
|
|
})
|
|
|
|
|
2023-05-08 12:25:48 +00:00
|
|
|
const isIOSorMacOSorAndroid = /iphone|ipad|ipod|macintosh|android/i.test(navigator.userAgent)
|
|
|
|
|
|
|
|
if (!isIOSorMacOSorAndroid) {
|
|
|
|
const htmlEl = document.querySelector('html')
|
|
|
|
htmlEl.dataset.customScroll = 'on'
|
|
|
|
}
|
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
const content = document.querySelector('#root')
|
|
|
|
|
|
|
|
if (!layoutReady) {
|
|
|
|
hydrate(
|
|
|
|
() => (
|
|
|
|
<MetaProvider>
|
|
|
|
<App {...pageProps} />
|
|
|
|
</MetaProvider>
|
|
|
|
),
|
|
|
|
content
|
|
|
|
)
|
|
|
|
layoutReady = true
|
|
|
|
}
|
|
|
|
}
|