feat(docs): add static generation and search indexes

This commit is contained in:
Maofeng
2026-09-20 16:23:32 +08:00
parent a57fdbe7c6
commit 9635de56e8
19 changed files with 529 additions and 169 deletions
+24 -7
View File
@@ -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)
}