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)
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import Link from 'next/link'
|
||||
import { DOC_CATEGORIES } from '@/lib/docs/nav'
|
||||
|
||||
export const metadata = {
|
||||
title: 'Docs',
|
||||
description:
|
||||
'Everything you need to run your space with hackerspace.sh — organized as tutorials, how-to guides, reference, and explanation.',
|
||||
}
|
||||
|
||||
export default function DocsHomePage() {
|
||||
return (
|
||||
<main className="docs-shell" style={{ gridTemplateColumns: '1fr' }}>
|
||||
<div className="docs-content" style={{ padding: 0 }}>
|
||||
<section className="docs-home-hero">
|
||||
<p className="docs-eyebrow">Documentation</p>
|
||||
<h1 className="docs-home-title">
|
||||
Run your space, <em>documented</em>
|
||||
</h1>
|
||||
<p className="docs-home-lede">
|
||||
Everything hackerspace.sh does, written down. Organized the{' '}
|
||||
<a
|
||||
href="https://diataxis.fr"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={{ color: 'var(--doc-accent)', textDecoration: 'underline' }}
|
||||
>
|
||||
Diátaxis
|
||||
</a>{' '}
|
||||
way: learn with tutorials, get things done with how-to guides, look up the
|
||||
details in reference, and understand the why in explanation.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<div className="docs-cat-grid">
|
||||
{DOC_CATEGORIES.map(cat => (
|
||||
<section key={cat.id} className="docs-cat-card">
|
||||
<p className="docs-cat-eyebrow">{cat.tagline}</p>
|
||||
<h2 className="docs-cat-title">{cat.label}</h2>
|
||||
<p className="docs-cat-diataxis">{cat.diataxis}</p>
|
||||
<div className="docs-cat-list">
|
||||
{cat.pages.map(page => (
|
||||
<Link key={page.slug} href={`/docs/${cat.id}/${page.slug}`}>
|
||||
{page.title}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user