2026-09-20 15:53:28 +08:00
|
|
|
import { StrictMode } from "react"
|
2026-09-20 16:23:32 +08:00
|
|
|
import { createRoot, hydrateRoot } from "react-dom/client"
|
2026-09-20 15:53:28 +08:00
|
|
|
|
|
|
|
|
import App from "./App.tsx"
|
2026-09-20 16:23:32 +08:00
|
|
|
// oxlint-disable-next-line import/no-unassigned-import -- The entry point installs the global stylesheet.
|
2026-09-20 15:53:28 +08:00
|
|
|
import "./index.css"
|
2026-09-20 16:23:32 +08:00
|
|
|
import { resolveDocLocale } from "./content/registry"
|
|
|
|
|
import {
|
|
|
|
|
createDefaultDocsPreferences,
|
|
|
|
|
initializeDocsPreferences,
|
|
|
|
|
} from "./lib/preferences"
|
2026-09-20 15:53:28 +08:00
|
|
|
|
2026-09-20 16:23:32 +08:00
|
|
|
const root = document.getElementById("root")!
|
|
|
|
|
const prerendered = root.hasChildNodes()
|
|
|
|
|
const locale = resolveDocLocale(window.location.pathname)
|
|
|
|
|
document.documentElement.lang = locale
|
2026-09-20 15:53:28 +08:00
|
|
|
|
|
|
|
|
initializeDocsPreferences()
|
|
|
|
|
|
2026-09-20 16:23:32 +08:00
|
|
|
const app = (
|
2026-09-20 15:53:28 +08:00
|
|
|
<StrictMode>
|
2026-09-20 16:23:32 +08:00
|
|
|
<App
|
|
|
|
|
initialPreferences={
|
|
|
|
|
prerendered ? createDefaultDocsPreferences(locale) : undefined
|
|
|
|
|
}
|
|
|
|
|
initialUrl={window.location.href}
|
|
|
|
|
/>
|
2026-09-20 15:53:28 +08:00
|
|
|
</StrictMode>
|
|
|
|
|
)
|
2026-09-20 16:23:32 +08:00
|
|
|
|
|
|
|
|
if (prerendered) {
|
|
|
|
|
hydrateRoot(root, app)
|
|
|
|
|
} else {
|
|
|
|
|
createRoot(root).render(app)
|
|
|
|
|
}
|