Files
hackerspace.sh/app/(docs)/docs/[category]/[slug]/page.tsx
T
Moheeb Zara 16229ae523 feat(docs): add a Diátaxis documentation section to the public site
A new public /docs area covering the whole platform, organized by Diátaxis:
tutorials (learning), how-to guides (tasks), reference (facts), and explanation
(the why). 29 pages, each grounded in the actual routes, actions, schema, and
UI — verified against the code and corrected for accuracy (e.g. admin-only vs
admin+board gating, where the permissions matrix actually lives, how Stripe
reconciliation matches).

Implementation:
- lib/docs/nav.ts is the single source of truth (categories + pages), driving
  the sidebar, static params, and prev/next.
- Content authored as content/docs/<category>/<slug>.md, read at build time
  (the routes are statically generated), rendered by <DocsMarkdown> — reuses the
  existing react-markdown/GFM stack, no new dependencies.
- (docs) route group with its own theme (docs.css) matching the public site's
  dark / monospace / lime aesthetic; sidebar with active-state, breadcrumb,
  prev/next, and a Diátaxis home. Public — signed-in users can read it too.
- "Docs" link added to the landing nav.

typecheck 0 · lint 0 errors · build ok (all /docs pages prerendered)
2026-08-05 00:42:42 -07:00

87 lines
2.9 KiB
TypeScript

import Link from 'next/link'
import { notFound } from 'next/navigation'
import { DOC_CATEGORIES, findPage, flatPages } from '@/lib/docs/nav'
import { loadDocContent } from '@/lib/docs/load'
import { DocsMarkdown } from '@/components/docs/docs-markdown'
import { DocsSidebar } from '@/components/docs/docs-sidebar'
export function generateStaticParams() {
return DOC_CATEGORIES.flatMap(cat =>
cat.pages.map(page => ({ category: cat.id, slug: page.slug })),
)
}
export const dynamicParams = false
type Params = { category: string; slug: string }
export async function generateMetadata({ params }: { params: Promise<Params> }) {
const { category, slug } = await params
const found = findPage(category, slug)
if (!found) return {}
return { title: found.page.title, description: found.page.summary }
}
export default async function DocPage({ params }: { params: Promise<Params> }) {
const { category, slug } = await params
const found = findPage(category, slug)
if (!found) notFound()
const { category: cat, page } = found
const content = await loadDocContent(cat.id, page.slug)
const flat = flatPages()
const idx = flat.findIndex(p => p.categoryId === cat.id && p.slug === page.slug)
const prev = idx > 0 ? flat[idx - 1] : null
const next = idx >= 0 && idx < flat.length - 1 ? flat[idx + 1] : null
return (
<main className="docs-shell">
<DocsSidebar />
<article className="docs-content">
<nav className="docs-breadcrumb" aria-label="Breadcrumb">
<Link href="/docs">Docs</Link>
<span>/</span>
<span>{cat.label}</span>
</nav>
<header className="docs-page-head">
<p className="docs-eyebrow">{cat.label}</p>
<h1 className="docs-page-title">{page.title}</h1>
<p className="docs-page-summary">{page.summary}</p>
</header>
<hr className="docs-rule" />
{content ? (
<DocsMarkdown content={content} />
) : (
<div className="docs-prose">
<p style={{ color: 'var(--doc-text-muted)' }}>
This page is being written. Check back shortly.
</p>
</div>
)}
<nav className="docs-pager" aria-label="Pagination">
{prev ? (
<Link href={`/docs/${prev.categoryId}/${prev.slug}`} className="docs-pager-prev">
<span className="docs-pager-dir">← Previous</span>
<span className="docs-pager-title">{prev.title}</span>
</Link>
) : (
<span />
)}
{next ? (
<Link href={`/docs/${next.categoryId}/${next.slug}`} className="docs-pager-next">
<span className="docs-pager-dir">Next →</span>
<span className="docs-pager-title">{next.title}</span>
</Link>
) : (
<span />
)}
</nav>
</article>
</main>
)
}