用这个模板做的 2 个案例
同一份提示词,不同的 [VARIABLES] 变量。点一个在上方预览。关于这个模板
一个单页三栏的 API 参考文档,面向虚构的 JSON API:左侧是粘性导航,按端点分组排列,带即时搜索框(纯客户端、支持键盘导航);中间是阅读栏,包含入门区块(基础 URL、一条带复制按钮的安装命令、三个快速开始步骤)和八个端点区块——方法标签、路径、描述、参数表格(名称、类型、是否必填、默认值、描述)、带 curl/JS/Python 标签页和可用复制按钮的代码示例,以及带状态标签和可折叠 JSON 的响应示例;右侧是「本页内容」锚点栏。默认文档记录的是一个虚构的 expenses API,但结构适用于任何 REST API。视觉风格是工作室浅色:纸色底、墨色文字、单一信号蓝强调色,深色面板中手工高亮的代码——没有高亮库,没有网络请求。所有内容都放在一个带类型的文件里;替换变量后,每条命令、URL 和示例都会根据品牌 slug 重写。
模板提示词
在线演示就是用这份提示词原样做出来的,没有额外补充。其他案例只是改了 [VARIABLES] 变量的值。 提示词保持英文原版,国内常用的 AI 编程工具都能直接理解;下面附中文参考译文。
# API Reference Docs Site
Build this website exactly as described below. Replace the [VARIABLES] with your own values; keep everything else.
## Brief
A one-page API reference for [BRAND], the JSON API for [PRODUCT], at version [VERSION]. Three columns: endpoint navigation with instant search, a reading column with a getting-started block and eight endpoint blocks (parameters, tabbed code samples with copy, response examples), and an on-this-page rail. One page, index.html; search, tabs, copy and collapse all run in the browser.
- Audience: A developer pasting their first request within five minutes: they want the base URL, an API-key line, honest parameter tables and copy-paste samples that actually match the schema.
- Goal: First successful call fast. Within ten seconds the visitor sees the base URL and install command; within two minutes they have copied a curl sample and found the endpoint they came for via search.
- Tone: Documentation-plain: short declarative sentences, no marketing voice, one dry joke in the errors block.
## Stack
- Framework: Vite 5 + React 18 + TypeScript
- Styling: Tailwind CSS 3.4
- Libraries: react (MIT), react-dom (MIT), motion (motion.dev, import from 'motion/react') (MIT), lucide-react (ISC), tailwindcss (MIT), postcss (MIT), autoprefixer (MIT), vite (MIT), @vitejs/plugin-react (MIT), typescript (Apache-2.0), @fontsource-variable/ibm-plex-sans (OFL-1.1), @fontsource/ibm-plex-mono (OFL-1.1)
- Build: `npm run build` → static files in `dist/`. No backend, no server code, no external APIs.
- Setup:
- Scaffold with npm create vite@latest using the react-ts template (pin the version if the latest template targets newer majors), then keep one real HTML page: index.html (entry src/main.tsx).
- vite.config.ts: base './', plugins [react()], build { outDir 'dist', sourcemap false, assetsInlineLimit 0 }. Do not copy src/ into dist/.
- Tailwind 3.4 through PostCSS, content ['./index.html', './src/**/*.{ts,tsx}']. In tailwind.config.ts add every color under Design to theme.extend.colors with kebab-case keys (paper, panel, line, ink, softink, blue, blue-deep, blue-mist, get, post, patch, del, codebg, codetext, codestring, codekey, codecomment) and fontFamily sans ['IBM Plex Sans Variable', 'system-ui', 'sans-serif'], mono ['IBM Plex Mono', 'ui-monospace', 'monospace']. Set borderRadius DEFAULT to 8px and add maxWidth { container: '1440px', read: '760px' }.
- In src/fonts.ts import '@fontsource-variable/ibm-plex-sans' and '@fontsource/ibm-plex-mono/400.css' plus '500.css' and '600.css'; import src/fonts.ts and src/index.css from the entry file.
- File layout: src/content.ts (every string, endpoint, parameter row, code line, response and error, typed — endpoints: { id, group, method, path, title, desc, params: { name, type, required, default, desc }[], samples: { curl, js, py }, response: { status, body }[] }), src/lib/brand.ts (brandSlug = [BRAND] lowercased with every run of non-alphanumeric characters replaced by '-', baseUrl = 'https://api.' + brandSlug without hyphens + '.dev/' + [VERSION], npmPackage = '@' + brandSlug without hyphens + '/client', keyHeader = 'Authorization: Bearer ' + brandSlug.toUpperCase() without hyphens + '_KEY'). Every URL, package name and command in content.ts is built from these helpers — nothing hard-codes the brand.
- src/lib/search.ts (score(query, endpoint) matching against title, path, group, param names and descriptions; returns ranked ids), src/lib/clipboard.ts (copy(text) using navigator.clipboard with a textarea fallback).
- State: src/store/docs.ts is a tiny external store (useSyncExternalStore) holding { query, activeEndpoint, copiedKey } — no persistence needed; search state resets on load.
- Components in src/components/: Header.tsx (with the inline SearchBox.tsx), EndpointNav.tsx (NavGroup.tsx, NavItem.tsx), OnThisPage.tsx (AnchorRow.tsx), GettingStarted.tsx (InstallLine.tsx with CopyButton.tsx), EndpointBlock.tsx (MethodChip.tsx, PathLine.tsx, ParamTable.tsx, CodeTabs.tsx with TabButton.tsx and CopyButton.tsx, ResponseBlock.tsx with StatusChip.tsx and JsonView.tsx), ErrorsBlock.tsx, Footer.tsx. src/pages/Docs.tsx composes them.
- CodeTabs: three tab buttons (curl / JavaScript / Python), roving tabindex with arrow keys, panels swapped with a 160ms crossfade; the CopyButton copies the active tab's raw text (kept in a hidden string, not scraped from the DOM) and shows a Check icon for 1.2s.
- Syntax highlighting is hand-rolled: samples are stored as plain strings and rendered by a tiny tokenizer in src/lib/highlight.ts (regex spans for strings, numbers, keys, comments and flags) into colored spans — no highlighter dependency.
- JsonView: pre-styled pretty JSON with the same tokenizer; a response header row carries StatusChip(s) (200 / 400) and a collapse toggle (rotating chevron) that animates max-height 240ms.
- Search: typing in the SearchBox filters the left nav live (non-matching items dim to 30% and sink), Enter focuses the first match's block, Escape clears; with an active query, non-matching EndpointBlocks in the reading column fade to 25% and a sticky 'N results · clear' bar shows above the column. All client-side.
- public/favicon.svg as described under Assets. index.html: lang en, <meta name='theme-color' content='#FAFAF8'>, <link rel='icon' href='./favicon.svg' type='image/svg+xml'>, <title>[BRAND] API — [VERSION] reference</title>.
- Write ASSETS.md at the project root as described under Assets.
- dist/ holds index.html, hashed JS/CSS, the woff2 fonts and favicon.svg. Keep it under 4 MB.
## Variables
- [BRAND] — API name (default: "Ledgerline"). The invented API's name, one word. Drives the wordmark, title, base URL (api.<brand>.dev), npm package (@<brand>/client), key header and every sample command. Never a real API.
- [PRODUCT] — What it serves (default: "expense data for small teams"). One lowercase phrase naming the domain. Rewrites the getting-started copy, group descriptions and endpoint one-liners. Keep it concrete.
- [VERSION] — API version (default: "v1"). The path prefix and version chip, like 'v1'. Keeps every sample URL consistent; no dates.
- [CREDIT] — keep a small "Template by VibeFather" link to https://vibefather.ai/t/api-reference-docs-site in the footer (default: yes; delete this line to remove it)
The copy under Pages & Sections is written for the default values. If your values differ, rewrite every headline, paragraph, label and image for them — same length, tone and structure. Layout, colors, type and motion stay as described.
Keep all copy, image paths and links in one content file (for example `src/content.ts`), keyed by section, so the content can be swapped later without touching components.Pro 模板
解锁完整提示词和源码
- 完整提示词:设计、版块、动效、素材
- 每个在线演示的源码
- 商用授权
在线演示和 DESIGN.md 仍然免费。
DESIGN.md
单独的设计规范:配色、字体、间距和动效。可以把这套视觉用到你已有的项目上。
---
name: "API Reference Docs Site"
colors:
paper: "#FAFAF8"
panel: "#FFFFFF"
line: "#E4E2DC"
ink: "#1B1F24"
soft_ink: "#61666D"
signal_blue: "#2E5BFF"
blue_deep: "#1F41C4"
blue_mist: "#EDF1FF"
get: "#157F4C"
post: "#2E5BFF"
patch: "#8A5CF6"
delete: "#C24040"
code_bg: "#14171C"
code_text: "#E8EAF0"
code_string: "#9DCE8C"
code_key: "#8FB5FF"
code_comment: "#6B7280"
typography:
text_and_display_h1_h2_nav_body_tables_ibm_plex_sans_neutral_with_personality_at_600: { family: "IBM Plex Sans", weights: [400, 500, 600] }
mono_paths_code_json_params_chips_ibm_plex_mono: { family: "IBM Plex Mono", weights: [400, 500] }
spacing: "8px base unit. Page: a 1440px container split into three columns — left nav 264px, center reading column max 760px, right rail 200px, gaps 40px; under 1100px the right rail hides; under 900px the nav collapses into a top drawer (hamburger in the header) and the reading column takes full width with 24px side padding. Section vertical rhythm 56px between endpoint blocks. Type scale: H1 (getting-started title) 36px Plex Sans 600; group headings 22px 600 with mono group slugs; endpoint titles 26px 600; body 15.5px / 1.7; descriptions 15px / 1.65 Soft Ink; eyebrow 12px 600 uppercase letter-spacing 0.14em Soft Ink; code and paths 13.5px / 1.65 Plex Mono; table text 14px. Buttons and inputs: height 40px; search input full nav width. Focus everywhere: 2px Signal Blue outline, 3px offset."
radius: "8px on code panels, tables, chips, search input, buttons. 6px on method chips and status chips (with 2px letter-spaced 10.5px labels)."
---
# API Reference Docs Site — Design System
Apply this design system to an existing project. It describes the look and feel only; for the full site, use prompt.md.
## Colors
- **Paper** `#FAFAF8` — Page background throughout.
- **Panel** `#FFFFFF` — Tables, nav, code panels sit on Paper; panels for hover and the search bar.
- **Line** `#E4E2DC` — 1px hairlines: column rules, table rows, borders, the sticky header underline.
- **Ink** `#1B1F24` — Headings, body, code path text.
- **Soft Ink** `#61666D` — Descriptions, captions, table defaults, eyebrows.
- **Signal Blue** `#2E5BFF` — The one accent: links, active nav item, focus ring, required asterisks, the version chip border.
- **Blue Deep** `#1F41C4` — Hover and pressed links.
- **Blue Mist** `#EDF1FF` — Active nav fill, selected tab underline wash, search highlight in nav.
- **GET** `#157F4C` — GET method chip fill and its PathLine method tag.
- **POST** `#2E5BFF` — POST method chip fill.
- **PATCH** `#8A5CF6` — PATCH method chip fill.
- **DELETE** `#C24040` — DELETE method chip fill and error status chips.
- **Code BG** `#14171C` — Code and JSON panel background.
- **Code Text** `#E8EAF0` — Default code text.
- **Code String** `#9DCE8C` — Strings and URLs in code.
- **Code Key** `#8FB5FF` — JSON keys and flags in code.
- **Code Comment** `#6B7280` — Comments and sample-value hints in code.
## Typography
- **Text and display: H1, H2, nav, body, tables — IBM Plex Sans, neutral with personality at 600** — IBM Plex Sans (OFL), weights 400/500/600. Self-host the font files.
- **Mono: paths, code, JSON, params, chips — IBM Plex Mono** — IBM Plex Mono (OFL), weights 400/500. Self-host the font files.
## Spacing & shape
- Spacing: 8px base unit. Page: a 1440px container split into three columns — left nav 264px, center reading column max 760px, right rail 200px, gaps 40px; under 1100px the right rail hides; under 900px the nav collapses into a top drawer (hamburger in the header) and the reading column takes full width with 24px side padding. Section vertical rhythm 56px between endpoint blocks. Type scale: H1 (getting-started title) 36px Plex Sans 600; group headings 22px 600 with mono group slugs; endpoint titles 26px 600; body 15.5px / 1.7; descriptions 15px / 1.65 Soft Ink; eyebrow 12px 600 uppercase letter-spacing 0.14em Soft Ink; code and paths 13.5px / 1.65 Plex Mono; table text 14px. Buttons and inputs: height 40px; search input full nav width. Focus everywhere: 2px Signal Blue outline, 3px offset.
- Radius: 8px on code panels, tables, chips, search input, buttons. 6px on method chips and status chips (with 2px letter-spaced 10.5px labels).
## Motion
- Easing: --ease-out cubic-bezier(0.22, 0.61, 0.36, 1). Documentation should feel like paper, not a carousel.
- Reveal: endpoint blocks rise 8px and settle over 400ms as they enter (Motion whileInView, once); no stagger needed between blocks.
- Tab swap: 160ms crossfade; the active tab's 2px Signal Blue underline slides (layout animation, 200ms).
- CopyButton: icon swaps FileCopy→Check with a 140ms scale pop, reverting after 1.2s.
- JsonView collapse: max-height animates 240ms; chevron rotates 180deg.
- Search: nav items dim/sink over 180ms; the results bar slides down 8px into place; matched nav text gets a Blue Mist highlight that persists while the query lives.
- Active nav tracking: the active item's 2px rail and Blue Mist fill follow scroll (no animation lag over 100ms).
- OnThisPage rail: active anchor gets a Signal Blue dot that slides between rows (200ms).
- prefers-reduced-motion: reduce — no reveals, no sliding underlines (plain swap), no dot sliding; everything sits still and works. Use CSS @media in index.css plus Motion's useReducedMotion.
## Imagery
No photographs, no illustrations, no logos: the page is typography, tables and code panels — the craft object is the layout itself. Method chips, status chips, the version chip and the favicon are drawn in code. Icons: lucide-react only, stroke width 1.75.
## Tone
Documentation-plain: short declarative sentences, no marketing voice, one dry joke in the errors block.
---
— Prompt by VibeFather · https://vibefather.ai/t/api-reference-docs-site · CC BY-NC 4.0 (non-commercial; commercial use needs a VibeFather Pro license) · Request removal: https://vibefather.ai/takedown
改成你自己的
- 一家支付初创公司:将 BRAND 设为你的网关名称,PRODUCT 设为银行卡和打款数据,并重写八个端点区块,用于收费、退款和 webhook。
- 一个内部平台团队:保留三栏布局,但把公开 API 密钥行替换为你的认证请求头,并且只记录你的服务调用的端点。
- 一位开发者工具创始人:将 VERSION 指向你当前的发布版本,把 expenses 示例换成你的核心资源,并保留复制按钮作为首次调用的路径。
- 一位开源维护者:将模板用作自托管 API 的托管参考文档,保留可折叠的 JSON 响应和入门安装命令。
API 参考文档站:常见问题
如何修改 API 参考文档站中的基础 URL、npm 包和 API 密钥请求头?
API 参考文档站用三个变量生成所有命令、URL 和示例:BRAND、PRODUCT 和 VERSION。把 BRAND 设为你的 API 名称,把 VERSION 设为你的版本前缀;模板会根据品牌 slug 推导出基础 URL、客户端包名和密钥请求头,因此你无需逐个编辑示例。所有内容都放在一个带类型的内容文件里,一次替换即可重写整个参考文档。
我可以把 API 参考文档站用于 GraphQL 或 gRPC API,而不是 REST 吗?
API 参考文档站围绕 REST 端点区块构建:方法标签、路径、参数表格和响应示例。如果用于 GraphQL API,需要把端点区块改造成查询和变更条目,并把 curl/JS/Python 标签页替换为查询示例。搜索、复制按钮、可折叠 JSON 和「本页内容」栏仍然适用,因此这个页面是一个合理的起点,但端点部分预计需要重写。
API 参考文档站中的即时搜索是如何工作的?需要服务器吗?
API 参考文档站中的搜索完全在浏览器中运行。输入时会实时过滤左侧端点导航,将不匹配的项变暗;按 Enter 跳转到第一个匹配项的区块,按 Escape 清空查询,阅读栏上方会出现一个粘性结果栏。匹配会对端点标题、路径、分组、参数名称和描述进行评分。没有网络请求,也没有后端,因此可以在任何静态托管上使用。
怎么用 AI 做一个API 参考文档站?
复制本页的完整提示词(Pro),或者运行 npx vibefather add api-reference-docs-site,把 [BRAND]、[PRODUCT]、[VERSION] 换成你自己的内容,再粘贴到 Claude Code、Codex、Cursor 等 AI 编程工具里。在线演示就是用这份提示词原样做出来的。
API 参考文档站模板的演示是哪个 AI 模型做的?
演示由 GLM-5.3 在 ZCode 里完成;另一个案例由 DeepSeek V4.1 Flash 在 DeepSeek Harness 里完成。每次都用公开的提示词原样生成,没有额外补充,可以并排比较不同模型的效果。