
內容簡介
Nahnu Code & API Block 是一款專為開發者設計的 WordPress 外掛,提供了完整的代碼和 API 文檔功能。它包含高亮語法的代碼區塊及多種專為 API 參考頁面設計的區塊,讓開發者能夠輕鬆展示和測試 API。
【主要功能】
• 支援 20 多種語言的語法高亮
• 自動適應訪客的淺色/深色模式
• API 文檔區塊包含端點、參數和狀態碼表
• 提供可編輯的即時請求控制台
• 一鍵複製按鈕和可選行號顯示
外掛標籤
開發者團隊
原文外掛簡介
Nahnu Code & API Block gives the block editor everything a developer-facing site needs to document code and APIs: a polished syntax-highlighted code block, and a matching family of blocks purpose-built for API reference pages — endpoints, parameter tables, tabbed request/response examples, status code tables, authentication headers, and a live try-it console.
The code block
Syntax highlighting for 20+ languages, powered by Prism.js and bundled with the plugin (no external CDN requests).
Automatic light/dark mode: follows the visitor’s OS preference, and can also follow a dark-mode class or attribute your theme or another plugin already sets on or
An optional per-block toggle button so visitors can flip a single code block between light and dark themes manually.
Long snippets collapse to a configurable preview height with a “View all code” button that opens the complete snippet in a modal.
One-click Copy button, optional line numbers.
The API-documentation blocks
Endpoint — HTTP method badge, path, summary, version badge, and an optional deprecation notice.
Parameters — a name / type / required-optional / description table.
Request / Response — tabbed code examples per language (cURL, JavaScript, Python, PHP, and more), each with Request and Response sub-tabs. Language selection is synced and remembered across every Request/Response block on the same page.
Status Codes — a table of the HTTP status codes your API returns, color-coded by class (2xx/3xx/4xx/5xx), with an optional collapsible example response body.
Authentication — shows the exact header a client needs to send (Bearer token, API key, Basic auth, or OAuth 2.0), with a copy button.
Try It Console — a live request form visitors can edit (URL, headers, body) and send directly from their own browser to see a real response. This performs a genuine client-side request; it never proxies or issues the call from your WordPress server.
All blocks share the same visual language and the same light/dark theming, so a full API reference page looks consistent throughout.
External services and data
Nahnu Code & API Block does not connect to any external service, API, or CDN at runtime, and does not collect, transmit, or store any personal data. The Prism.js syntax-highlighting library is bundled with the plugin files (MIT licensed) rather than loaded from a third-party server. The Try It Console block is the one exception worth being explicit about: when a site visitor clicks “Send request” on that block, their own browser makes a direct HTTP request to whatever URL is shown in that block (which the page author configured, and the visitor can edit). That request comes from the visitor’s browser, not from your WordPress server, and nothing about it is seen by this plugin’s author or by Nahnu.
