fix paths for build
This commit is contained in:
@@ -1,49 +0,0 @@
|
|||||||
import clsx from "clsx"
|
|
||||||
import React from "react"
|
|
||||||
import { guideLinks } from "../data/guide-links"
|
|
||||||
import { useScrolled } from "../hooks/dom/use-scrolled"
|
|
||||||
import {
|
|
||||||
docsProseClass,
|
|
||||||
linkClass,
|
|
||||||
maxWidthContainer,
|
|
||||||
} from "../styles/components"
|
|
||||||
import { AppLink } from "./app-link"
|
|
||||||
import { MainNavigation } from "./main-navigation"
|
|
||||||
|
|
||||||
export function GuidePageLayout() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<HeaderPanel>
|
|
||||||
<div className={maxWidthContainer}>
|
|
||||||
<MainNavigation />
|
|
||||||
</div>
|
|
||||||
</HeaderPanel>
|
|
||||||
<main className={clsx(maxWidthContainer, "mt-8 flex items-start gap-4")}>
|
|
||||||
<nav className="w-48 sticky top-24 hidden md:block">
|
|
||||||
<h2 className="text-2xl">Guides</h2>
|
|
||||||
<ul className="mt-3 flex flex-col gap-2 items-start">
|
|
||||||
{guideLinks.map((link) => (
|
|
||||||
<li key={link.to}>
|
|
||||||
<AppLink {...link} className={linkClass} />
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
<section className={clsx(docsProseClass, "pb-8 flex-1 min-w-0")}>
|
|
||||||
{/* todo */}
|
|
||||||
</section>
|
|
||||||
</main>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function HeaderPanel({ children }: { children: React.ReactNode }) {
|
|
||||||
const isScrolled = useScrolled()
|
|
||||||
|
|
||||||
const className = clsx(
|
|
||||||
isScrolled ? "bg-slate-700/30" : "bg-slate-800",
|
|
||||||
"shadow sticky top-0 backdrop-blur-sm transition z-10 flex",
|
|
||||||
)
|
|
||||||
|
|
||||||
return <header className={className}>{children}</header>
|
|
||||||
}
|
|
||||||
7
packages/docs/src/constants.ts
Normal file
7
packages/docs/src/constants.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { join } from "node:path"
|
||||||
|
|
||||||
|
const projectRoot = new URL("../", import.meta.url).pathname
|
||||||
|
|
||||||
|
export function fromProjectRoot(...subPaths: string[]) {
|
||||||
|
return join(projectRoot, ...subPaths)
|
||||||
|
}
|
||||||
@@ -3,8 +3,9 @@ import grayMatter from "gray-matter"
|
|||||||
import { readFile } from "node:fs/promises"
|
import { readFile } from "node:fs/promises"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import type { AppLinkProps } from "../components/app-link"
|
import type { AppLinkProps } from "../components/app-link"
|
||||||
|
import { fromProjectRoot } from "../constants"
|
||||||
|
|
||||||
const docsFolderPath = new URL("../docs", import.meta.url).pathname
|
const docsFolderPath = fromProjectRoot("src/docs")
|
||||||
const guideFiles = await glob("**/*.md", { cwd: docsFolderPath })
|
const guideFiles = await glob("**/*.md", { cwd: docsFolderPath })
|
||||||
|
|
||||||
const entries = await Promise.all(
|
const entries = await Promise.all(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import httpTerminator from "http-terminator"
|
|||||||
import pino from "pino"
|
import pino from "pino"
|
||||||
import pinoHttp from "pino-http"
|
import pinoHttp from "pino-http"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
import { fromProjectRoot } from "./constants"
|
||||||
import { renderMarkdownFile } from "./helpers/markdown"
|
import { renderMarkdownFile } from "./helpers/markdown"
|
||||||
import { sendJsx } from "./helpers/send-jsx"
|
import { sendJsx } from "./helpers/send-jsx"
|
||||||
import { serveCompiledScript } from "./helpers/serve-compiled-script"
|
import { serveCompiledScript } from "./helpers/serve-compiled-script"
|
||||||
@@ -29,19 +30,19 @@ const router = Router()
|
|||||||
|
|
||||||
.get(
|
.get(
|
||||||
"/prism-theme.css",
|
"/prism-theme.css",
|
||||||
serveFile(new URL("./styles/prism-theme.css", import.meta.url).pathname),
|
serveFile(fromProjectRoot("src/styles/prism-theme.css")),
|
||||||
)
|
)
|
||||||
|
|
||||||
.get(
|
.get(
|
||||||
"/popover-menu.client.js",
|
"/popover-menu.client.js",
|
||||||
await serveCompiledScript(
|
await serveCompiledScript(
|
||||||
new URL("./components/popover-menu.client.tsx", import.meta.url).pathname,
|
fromProjectRoot("src/components/popover-menu.client.tsx"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
.get("/docs/*", async (req: Request<{ 0: string }>, res) => {
|
.get("/docs/*", async (req: Request<{ 0: string }>, res) => {
|
||||||
const { html, data } = await renderMarkdownFile(
|
const { html, data } = await renderMarkdownFile(
|
||||||
`src/docs/${req.params[0]}.md`,
|
fromProjectRoot(`src/docs/${req.params[0]}.md`),
|
||||||
)
|
)
|
||||||
sendJsx(
|
sendJsx(
|
||||||
res,
|
res,
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import packageJson from "reacord/package.json"
|
import packageJson from "reacord/package.json"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { MainNavigation } from "../components/main-navigation"
|
import { MainNavigation } from "../components/main-navigation"
|
||||||
|
import { fromProjectRoot } from "../constants"
|
||||||
import { renderMarkdownFile } from "../helpers/markdown"
|
import { renderMarkdownFile } from "../helpers/markdown"
|
||||||
import { Html } from "../html"
|
import { Html } from "../html"
|
||||||
import { maxWidthContainer } from "../styles/components"
|
import { maxWidthContainer } from "../styles/components"
|
||||||
|
|
||||||
const landingExample = await renderMarkdownFile(
|
const landingExample = await renderMarkdownFile(
|
||||||
new URL("../components/landing-example.md", import.meta.url).pathname,
|
fromProjectRoot("src/components/landing-example.md"),
|
||||||
)
|
)
|
||||||
|
|
||||||
export function Landing() {
|
export function Landing() {
|
||||||
|
|||||||
Reference in New Issue
Block a user