5.0 KiB
5.0 KiB
svc.plus Frontend Routing Design
This document outlines the routing plan and page skeleton for the svc.plus site
implemented with Next.js 14 App Router and exported as static HTML (output: 'export').
The site uses TypeScript and Tailwind CSS. All pages are statically generated at
build time; runtime servers are not required.
Routes Overview
| Route | Description | Page File | Components | Data Source |
|---|---|---|---|---|
/ |
Site home with entry cards to Downloads and Docs | app/page.tsx |
custom Card components |
static |
/download/ |
Downloads browser with sidebar of roots and card grid of subfolders | app/download/page.tsx |
DownloadBrowser, CardGrid |
dl.svc.plus manifest.json + per-root dir.json |
/download/<name>/[...path] |
File listing for any nested folder | app/download/[name]/[[...path]]/page.tsx |
FileTable |
per‑folder JSON fetched at build time |
/docs/ |
Docs home listing available ebooks | app/docs/page.tsx |
optional DocCard grid |
local content/ processed by Contentlayer |
/docs/<name> |
Reading page for a single ebook | app/docs/[name]/page.tsx |
reader layout with side TOC | content/<name>/** Markdown files |
Directory Structure
app/
page.tsx # Home
download/
page.tsx # Downloads home
[name]/
[[...path]]/
page.tsx # File listings for arbitrary depth
docs/
page.tsx # Docs home
[name]/
page.tsx # Ebook reader
content/ # Markdown sources for docs
ui/
dl/
components/
CardGrid.tsx
FileTable.tsx
DownloadBrowser.tsx
docs/
components/ # (optional) shared doc components
Static Generation Requirements
Downloads
scripts/fetch-dl-index.tsrecursively crawlshttps://dl.svc.plus/(overridable byDL_BASE) and writespublic/dl-index/top.jsonandpublic/dl-index/all.json.top.jsonfeeds the downloads home whileall.jsoncontains aDirListing[]with every directory and itsDirEntrychildren. The script runs automatically via theprebuildnpm script.types/download.tsdefines shared types:interface DirEntry { name; href; type: 'file'|'dir'; size?; lastModified?; sha256? } interface DirListing { path; entries: DirEntry[] }- Use
all.jsonto enumerate every/<name>/path/...combination. - Implement
generateStaticParamsinapp/download/[name]/[[...path]]/page.tsxto return{ name, path?: string[] }for each known directory including the empty path. - Implement
generateMetadatato set titles and OpenGraph info for each folder. - Render a
FileTablewith breadcrumb navigation and sorting by name/size/time. - Downloads home consumes
https://dl.svc.plus/manifest.jsonand per-rootdir.jsonat runtime to build the sidebar and card grid.
Docs
- Store Markdown under
content/<doc>/<chapter>.md. - Configure Contentlayer to parse metadata (title, cover, order, etc.).
app/docs/page.tsxqueries the Contentlayer output to list available docs.app/docs/[name]/page.tsxloads chapters for the given doc and renders a reader with a sidebar table of contents, progress indicator, and intra‑page anchors for navigation.- Implement
generateStaticParamsfor/docs/[name]based onallDocsfrom Contentlayer, andgenerateMetadatafor SEO and OpenGraph.
CodeX Automation Prompt
Use the following step‑by‑step tasks for automated implementation.
-
Initialize Next.js project
- Create a Next.js 14 project in
ui/withoutput: 'export'and Tailwind CSS. - Acceptance: running
npm run buildproduces staticout/directory.
- Create a Next.js 14 project in
-
Home Page
- Implement
app/page.tsxwith two cards linking to/download/and/docs/. - Acceptance: cards render with Tailwind styling.
- Implement
-
Downloads Sub‑site
- Add
CardGridandFileTablecomponents underui/dl/components/. - Use
types/download.tsand runpnpm prebuildto fetch directory JSON during build.CardGridprops:sections: { key; title; href; lastModified?; count? }[].FileTableprops:listing: DirListing,breadcrumb: { label; href }[]. - Implement
generateStaticParamsandgenerateMetadataforapp/download/[name]/[[...path]]/page.tsx. - Acceptance: visiting any known folder in exported build shows correct listing.
- Add
-
Docs Sub‑site
- Configure Contentlayer for
content/Markdown. - Create
app/docs/page.tsxthat lists docs andapp/docs/[name]/page.tsxthat renders a reader with sidebar TOC and navigation anchors. - Acceptance: static export contains pages for all docs with working navigation.
- Configure Contentlayer for
-
Build Validation
- Run
pnpm i && pnpm build && pnpm exportto ensure a full static export. - Acceptance: the
out/directory contains working/download/and/docs/pages, e.g./download/offline-package/k3s/renders a file table and/docs/<name>retains reading progress.
- Run