feat(docs): add static generation and search indexes
This commit is contained in:
+24
-7
@@ -1,18 +1,35 @@
|
||||
import { StrictMode } from "react"
|
||||
import { createRoot } from "react-dom/client"
|
||||
import { createRoot, hydrateRoot } from "react-dom/client"
|
||||
|
||||
import App from "./App.tsx"
|
||||
// oxlint-disable-next-line import/no-unassigned-import -- The entry point installs the global stylesheet.
|
||||
import "./index.css"
|
||||
import { initializeDocsPreferences } from "./lib/preferences"
|
||||
import { resolveDocLocale } from "./content/registry"
|
||||
import {
|
||||
createDefaultDocsPreferences,
|
||||
initializeDocsPreferences,
|
||||
} from "./lib/preferences"
|
||||
|
||||
document.documentElement.lang = window.location.pathname.startsWith("/en-US")
|
||||
? "en-US"
|
||||
: "zh-Hans"
|
||||
const root = document.getElementById("root")!
|
||||
const prerendered = root.hasChildNodes()
|
||||
const locale = resolveDocLocale(window.location.pathname)
|
||||
document.documentElement.lang = locale
|
||||
|
||||
initializeDocsPreferences()
|
||||
|
||||
createRoot(document.getElementById("root")!).render(
|
||||
const app = (
|
||||
<StrictMode>
|
||||
<App />
|
||||
<App
|
||||
initialPreferences={
|
||||
prerendered ? createDefaultDocsPreferences(locale) : undefined
|
||||
}
|
||||
initialUrl={window.location.href}
|
||||
/>
|
||||
</StrictMode>
|
||||
)
|
||||
|
||||
if (prerendered) {
|
||||
hydrateRoot(root, app)
|
||||
} else {
|
||||
createRoot(root).render(app)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user