81 lines
3.2 KiB
Markdown
81 lines
3.2 KiB
Markdown
# Content / Blog & Docs — Next.js (templates2)
|
||
|
||
A **ready-to-run** content site: markdown-ish posts and docs with frontmatter-style fields
|
||
(title, slug, date, tags, author, draft), a table of contents, code highlighting, taxonomy,
|
||
server-side search, RSS/sitemap, JSON-LD and a **role-gated authoring admin** — all working on
|
||
the first run.
|
||
|
||
> Built by forking [`Base.Next`](../Base.Next); it inherits auth, roles, Prisma, mock payments
|
||
> and email, the admin shell, SEO, i18n, CI and Docker.
|
||
|
||
## Quickstart
|
||
|
||
```bash
|
||
npm ci
|
||
cp .env.example .env # SQLite + mock providers by default — no keys needed
|
||
npm run db:setup # prisma db push + seed
|
||
npm run dev # http://localhost:3000
|
||
```
|
||
|
||
Demo accounts (seeded), password `password`:
|
||
|
||
| Role | Email | Can do |
|
||
|---|---|---|
|
||
| admin | `admin@example.com` | everything, incl. users & audit |
|
||
| editor | `editor@example.com` | author posts and docs |
|
||
| user | `user@example.com` | read-only |
|
||
|
||
## What works out of the box
|
||
|
||
- **Content** — posts and docs stored in Prisma (authored in the admin, not hard-coded), rendered by
|
||
an in-repo markdown renderer with a table of contents, fenced-code highlighting + language labels,
|
||
lists, quotes, links and inline formatting.
|
||
- **Public site** — paginated `/blog`, post pages with byline + related posts, `/docs` grouped by
|
||
section with a sidebar and prev/next, `/tags`, `/authors/[slug]` and a server-side `/search`.
|
||
- **Authoring admin** — `/admin/posts` and `/admin/docs`: create/edit/preview/publish/**draft**,
|
||
featured posts, tag multi-select, with live preview; server API under `/api/admin/posts` and
|
||
`/api/admin/docs` enforces the role and writes an audit entry.
|
||
- **Feeds/SEO** — `sitemap.xml` (posts, docs, tags, authors), `rss.xml`, per-post metadata and
|
||
JSON-LD `Article`.
|
||
- **Core** — auth + roles, mock payments/email, admin shell, `/api/health`, both themes,
|
||
responsive to 360 px, WCAG AA contrast.
|
||
|
||
## Markdown support
|
||
|
||
Extending the base's minimal renderer (no `mdx`/`remark`/`gray-matter` dependency): `#`–`###`
|
||
headings, paragraphs, ordered/unordered lists, blockquotes, `---`, `**bold**`, `*italic*`,
|
||
`` `inline code` ``, `[links](/path)`, and fenced code blocks with a language label and lightweight
|
||
syntax highlighting.
|
||
|
||
## Data model
|
||
|
||
`prisma/schema.prisma`: `Author`, `Tag`, `PostTag`, `Post`, `Doc` (plus the base `User`,
|
||
`Session`, `Subscription`, `AuditLog`). SQLite in development; point `DATABASE_URL` at Postgres
|
||
for production.
|
||
|
||
## Scripts
|
||
|
||
| Script | What it does |
|
||
|---|---|
|
||
| `npm run dev` | Dev server with HMR |
|
||
| `npm run build` / `npm start` | Production build / serve |
|
||
| `npm run lint` / `npm run typecheck` | ESLint / `tsc --noEmit` |
|
||
| `npm test` | Unit tests (Vitest) |
|
||
| `npm run test:e2e` | HTTP end-to-end smoke (server must be running) |
|
||
| `npm run db:setup` | `prisma db push` + seed |
|
||
|
||
## Deployment
|
||
|
||
```bash
|
||
docker compose -f docker/docker-compose.yml up --build
|
||
```
|
||
|
||
## Quality
|
||
|
||
```bash
|
||
node ../templates2/qa.mjs Content.Next # from the repo root: node templates2/qa.mjs Content.Next
|
||
```
|
||
|
||
The harness isolates a clean copy, then runs install → verify → test → build → boot → routes →
|
||
e2e → screenshot. See [`../CONTRACT.md`](../CONTRACT.md) for the Definition of Done.
|