Skip to content

pantoken / demo

demo

@pantoken/demo@demo 系統的呈現端。

@pantoken/typedoc-plugin-demo turns a @demo <spec> tag into a fenced demo block whose body is the spec (a bare URL or a <provider>:<ref> pair). This package resolves that spec into an embeddable iframe and renders the surrounding panel — an MDN-style "live sample."

它包含三個部分: resolveDemo (spec → iframe 屬性、與框架無關),一個 markdown-it 外掛(demoMarkdownIt),將 demo 代碼區塊轉換成面板的 HTML,以及一個 自我託管的執行器(@pantoken/demo/runner.html)— 一個同源頁面,會擷取裸 HTML/CSS/JS 範例並在注入你的 token 樣式表後進行渲染,因此 self: 範例不需要第三方帳號或任何關於 framing 的變通方法。

範例

ts
import { resolveDemo } from "@pantoken/demo";

resolveDemo("stackblitz:abc123").src; // → "https://stackblitz.com/edit/abc123?embed=1&…"
resolveDemo("self:button", { base: "/docs/", cssUrls: ["/docs/tokens.css"] }).src;

介面

變數

函式