use vite-plugin-ssr

This commit is contained in:
MapleLeaf
2022-01-02 17:10:29 -06:00
committed by Darius
parent 336e680b6e
commit bfe12c9bcd
18 changed files with 203 additions and 242 deletions

View File

@@ -1,41 +1,14 @@
import { description } from "reacord/package.json"
import { lazy, Suspense } from "react"
import { Meta, Title } from "react-head"
import { Route, Routes } from "react-router-dom"
import { GuidePageLayout } from "./components/guide-page-layout"
import { LandingPage } from "./pages/landing-page"
import "tailwindcss/tailwind.css"
import "./styles/prism-theme.css"
export function App() {
export function App({ children }: { children: React.ReactNode }) {
return (
<>
<Title>Reacord</Title>
<Meta name="description" content={description} />
<Routes>
<Route path="/" element={<LandingPage />} />
<Route path="docs" element={<GuidePageLayout />}>
{docs.map(({ route, component: Component }) => (
<Route
key={route}
path={route}
element={
<Suspense fallback={<></>}>
<Component />
</Suspense>
}
/>
))}
</Route>
</Routes>
{children}
</>
)
}
const docs = Object.entries(import.meta.glob("./docs/*.md")).map(
([path, loadModule]) => ({
route: path.replace("./docs/", "").replace(/\.md$/, ""),
component: lazy(async () => {
const m = await loadModule()
return { default: m.default || m }
}),
}),
)