webapp/src/renderer/_default.page.client.tsx

38 lines
906 B
TypeScript
Raw Normal View History

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'
})
const content = document.querySelector('#root')
if (!layoutReady) {
hydrate(
() => (
<MetaProvider>
<App {...pageProps} />
</MetaProvider>
),
content
)
layoutReady = true
}
}