跳转到内容

文档站与在线演示

Astro 把文档和演示打成一个静态站。Starlight 提供侧栏和搜索,React 集成负责渲染组件。

  1. 在 apps/doc/src/content/docs/ 新增文件。例如 components/example.mdx 对应 /components/example/。
  2. 写好 title 和 description,再到 apps/doc/astro.config.mjs 的 sidebar 加上 components/example。

站点标题、中文根路径和 Rapide 主题都在 astro.config.mjs。文档布局样式放在 src/styles/custom.css。

src/pages/playground.astro 对应 /playground/。它渲染 src/components/demo.tsx,后者从 @dingshaohuax/md-editor 导入默认导出的 Editor。client:load 让编辑器在浏览器中支持交互。

---
import Demo from "../components/demo";
---
<Demo client:load />

正文链接用相对路径,Astro 页面用 import.meta.env.BASE_URL 拼站内链接。本地预览和 Pages 都从根路径提供文档和演示。