添加或更新插件
复制一个包含安装步骤和本插件 Markdown 指南的 AI 配置提示。
本指南解释了如何将新 Capacitor 插件添加到 Capgo 网站或更新现有插件文档。这对贡献者、维护者和帮助维护文档的 AI agent 都很有用。
概述
概述当添加新插件到 Capgo 生态系统时,您需要更新网站中多个文件和位置,以确保插件在所有相关位置都正确显示:
- 插件列表配置 - 将插件元数据添加到主列表
- 插件索引页面 - 将插件添加到分类的插件列表页面
- 侧边栏导航 - 将插件添加到文档侧边栏
- 插件文档 - 创建概述和快速入门页面
- 插件教程 - 创建全面教程
文件位置
标题为“文件位置”的部分需要更新的关键文件
标题为“需要更新的关键文件”的部分| 文件 | 目的 |
|---|---|
/src/config/plugins.ts | 主插件列表 |
/src/content/docs/docs/plugins/index.mdx | 插件索引 |
/astro.config.mjs | 侧边栏配置 |
/src/content/docs/docs/plugins/[plugin-name]/ | 插件文档 |
/src/content/plugins-tutorials/en/ | 英文教程 |
逐步指南
逐步指南-
添加插件
添加插件打开
/src/config/plugins.ts并将您的插件添加到actionsarray:// First, import an appropriate Heroiconimport YourIconName from 'astro-heroicons/mini/IconName.astro'// Then add to the actions array{name: '@capgo/your-plugin-name',author: 'github.com/Cap-go',description: 'Brief description of what the plugin does',href: 'https://github.com/Cap-go/your-plugin-name/',title: 'Display Name',icon: YourIconName,}可用图标: 检查
/node_modules/astro-heroicons/mini/可用图标 -
添加插件到首页
添加插件到首页打开
/src/content/docs/docs/plugins/index.mdx并在适当分类下添加您的插件:<LinkCardtitle="Your Plugin Name"description="Brief description of what the plugin does"href="/docs/plugins/your-plugin-name/"/>分类:
- ⭐推荐插件
- 📱 设备 & 系统插件
- 🎥 媒体 & 相机插件
- 🛠️ 工具插件
- 🤖 AI & 高级媒体
- 📍 位置 & 后台服务
- 📞 通信 & 分析
- 🔐 安全 & 系统
- 📊 Android-特定功能
- 📥 下载 & 导航
-
添加到侧边栏导航
标题:添加到侧边栏导航打开
/astro.config.mjs并在侧边栏配置 (约在行 540) 中添加您的插件:{label: 'Your Plugin Name',items: [{ label: 'Overview', link: '/docs/plugins/your-plugin-name/' },{ label: 'Getting started', link: '/docs/plugins/your-plugin-name/getting-started' },],collapsed: true,}复制到剪贴板
-
创建插件文档目录
插件按字母顺序列在侧边栏中。创建插件文档目录
标题:创建插件文档目录 mkdir -p /src/content/docs/docs/plugins/your-plugin-name/ -
创建一个用于您的插件文档的新目录:
终端窗口创建插件概览页面
/src/content/docs/docs/plugins/your-plugin-name/index.mdx:---title: "@capgo/your-plugin-name"description: Brief description of the plugin's purposetableOfContents: falsenext: falseprev: falsesidebar:order: 1label: "Introduction"hero:tagline: Detailed tagline explaining what the plugin doesimage:file: ~public/your-plugin-icon.svgactions:- text: Get startedlink: /docs/plugins/your-plugin-name/getting-started/icon: right-arrowvariant: primary- text: Githublink: https://github.com/Cap-go/your-plugin-name/icon: externalvariant: minimal---import { Card, CardGrid } from '@astrojs/starlight/components';<CardGrid stagger><Card title="Feature 1" icon="puzzle">Description of first key feature</Card><Card title="Feature 2" icon="rocket">Description of second key feature</Card><Card title="Cross-platform" icon="puzzle">Works on both iOS and Android 📱</Card><Card title="Comprehensive Documentation" icon="open-book">Check the [Documentation](/docs/plugins/your-plugin-name/getting-started/) to master the plugin.</Card></CardGrid> -
创建开始使用指南
创建开始使用指南创建
/src/content/docs/docs/plugins/your-plugin-name/getting-started.mdx:---title: Getting Starteddescription: Learn how to install and use the plugin in your Capacitor app.sidebar:order: 2---import { Steps } from '@astrojs/starlight/components';import { PackageManagers } from 'starlight-package-managers'<Steps>1. **Install the package**<PackageManagers pkg="@capgo/your-plugin-name" pkgManagers={['npm', 'pnpm', 'yarn', 'bun']} />2. **Sync with native projects**<PackageManagers type="exec" pkg="cap" args="sync" pkgManagers={['npm', 'pnpm', 'yarn', 'bun']} /></Steps>## Configuration### iOS Configuration[iOS-specific setup instructions]### Android Configuration[Android-specific setup instructions]## Usage[Basic usage examples]## API Reference[Detailed API documentation]## Complete Example[Full working example]## Best Practices[Recommended practices and tips]## Platform Notes[Platform-specific notes and limitations] -
创建教程文件
创建教程文件创建
/src/content/plugins-tutorials/en/your-plugin-name.md:---locale: en---# Using @capgo/your-plugin-name PackageThe `@capgo/your-plugin-name` package [brief description]. In this tutorial, we will guide you through the installation, configuration, and usage of this package in your Ionic Capacitor app.## Installation[Installation steps]## Configuration[Configuration steps for iOS and Android]## API Usage[Detailed API usage examples]## Complete Example[Full working example]## Best Practices[Tips and best practices]## Troubleshooting[Common issues and solutions]## Conclusion[Summary and links to additional resources]
插件文档结构
插件文档结构必需文件
必需文件src/content/docs/docs/plugins/your-plugin-name/├── index.mdx # Overview page with hero and feature cards└── getting-started.mdx # Installation and usage guide
src/content/plugins-tutorials/en/└── your-plugin-name.md # Comprehensive tutorial可选文件
可选文件对于复杂的插件,您可能需要添加额外的文档页面:
src/content/docs/docs/plugins/your-plugin-name/├── index.mdx├── getting-started.mdx├── api-reference.mdx # Detailed API documentation├── examples.mdx # Additional examples├── troubleshooting.mdx # Troubleshooting guide└── migrations.mdx # Migration guides内容指南
可选文件编写插件描述
简洁- : 描述长度不超过100个字符具体
- 复制到剪贴板: 描述插件的功能,而不是它是什么
- 使用动词: 以“控制”,“整合”,“启用”等动词开始
好的例子:
- “使用简单的开关控制设备闪光灯和手电筒”
- “将 Crisp 实时聊天和客户支持整合到您的应用中”
- “使用 Face ID 和 Touch ID 启用安全认证”
坏的例子:
- “用于闪光的插件”
- “这是一个 Crisp 插件”
- “生物识别插件”
- 开始安装Always begin with clear installation steps
- 提供配置Include platform-specific setup requirements
- 使用示例Provide working code examples
- 包含 API 参考Document all methods and parameters
- 添加完整示例Show real-world usage patterns
- 最佳实践列表: 最佳实践使用技巧
- 文档平台差异: iOS 与 Android 行为差异
- 添加故障排除: 常见问题
Code 示例
标题:Code 示例- 使用 TypeScript 为所有 code 示例
- 在顶部包含导入
- 添加解释关键步骤的注释
- 显示错误处理
- 演示基本和高级使用
检查清单
标题:检查清单在添加新插件时,请使用此检查清单:
- 已添加插件到
/src/config/plugins.ts - 从 Heroicons 中选择了合适的图标
- 已添加插件到
/src/content/docs/docs/plugins/index.mdx在正确的类别下 - 在侧边栏中添加了插件条目
/astro.config.mjs - 创建了插件文档目录
- 创建了
index.mdx概述页面 - 创建了
getting-started.mdx指南 - 创建了教程
/src/content/plugins-tutorials/en/ - 包含了安装说明
- 文档了iOS配置
- 文档了Android配置
- 提供了使用示例
- 添加了API参考
- 包含了完整的工作示例
- 列出了最佳实践
- 添加了平台特定说明
- 测试了所有链接正确工作
图标参考
图标参考插件中常用图标(来自 astro-heroicons/mini/):
| Icon | 用途 |
|---|---|
BoltIcon | context |
CameraIcon | Page/area: Capgo solutions marketing page. Role: Short UI label or navigation item. Seen in: page solutions/cordova-to-capacitor-ai.astro. Message key `solutions_cordova_to_capacitor_ai_table_use_case` (Solutions Cordova To Capacitor Ai Table Use Case). |
ChatBubbleLeftIcon | 闪烁,电源,能源 |
FingerPrintIcon | 摄像头,照片,视频 |
MapPinIcon | 聊天,信息,沟通 |
SpeakerWaveIcon | 生物识别,安全,身份验证 |
VideoCameraIcon | 位置,地理位置,地图 |
CreditCardIcon | 音频,声音,音乐 |
PlayCircleIcon | 多媒体播放器, 视频播放器 |
SignalIcon | 连接, 网络, 蓝牙 |
RadioIcon | 蓝牙, 广播, 无线 |
ChatBubbleOvalLeftIcon | 社交媒体, 微信 |
更新现有插件
标题:更新现有插件更新现有插件时:
- 更新版本号 在文档中
- 添加迁移指南 如果存在破坏性更改
- 更新API引用 使用新方法
- 添加新示例 为新功能
- 更新平台要求 如果发生变化
- 根据新功能 修订最佳实践
- 保持教程最新 与最新API
语言路径
标题为“语言路径”在英语中编写和审阅插件文档。 本地化路径由站点元数据生成并在边缘由翻译工人翻译。
测试您的更改
测试您的更改添加或更新插件文档后:
-
本地构建站点:
终端窗口 bun run build -
检查错误:
- 验证所有链接正常工作
- 确保图片正确加载
- 确认code示例有效
- 测试导航
-
预览站点:
终端窗口 bun run dev -
您的插件已显示:
- 检查插件列表页面
- 验证侧边栏导航
- 测试所有文档页面
- 确认教程页面正常工作
常见问题
注意获取帮助
标题:获取帮助如果您需要帮助添加或更新插件文档:
- Discord: 加入我们的 Discord 社区
- GitHub: 在我们的 网站仓库中打开一个问题
- 邮箱: 联系团队 support@capgo.app
示例
示例部分为了参考,请检查这些文档齐全的插件:
- 更新器:
/src/content/docs/docs/plugins/updater/(复杂插件,具有多个页面) - 闪烁:
/src/content/docs/docs/plugins/flash/(简单插件,适合作为示例) - 社交登录:
/src/content/docs/docs/plugins/social-login/(具有子页面的插件)
概要
概要将插件添加到Capgo文档中涉及:
- 添加元数据到主配置
- 将插件添加到分类索引页面
- 配置侧边栏导航
- 创建全面文档页面
- 编写详细教程
- 测试所有更改
通过遵循本指南,您确保插件的文档一致且易于用户发现。
继续阅读添加或更新插件
继续阅读添加或更新插件如果您正在使用 添加或更新插件 用于规划原生插件工作,连接它与 Capgo 插件目录 为产品工作流程在 Capgo 插件目录中 Capacitor 插件由 Capgo 为实现细节在 Capacitor 插件由 Capgo 中 Ionic 企业插件替代品 用于产品工作流程在 Ionic 企业插件替代品中 Capgo 原生构建 用于产品工作流程在 Capgo 原生构建中, Capacitor 插件:您需要知道的 为 Capacitor 的实际上下文在插件中:您需要知道的内容。