VitePress 插件贡献器
A 类 虚拟新闻 用于轻松生成、更新和显示寄存器的插件. 支持GitHub(包括企业)和Forgejo(Gitea,Codeberg等).
这个 软件包 包括可以一起或单独使用的两个组件.
安装
- 直接安装到您的 VitePress 从 无。 。 。 .
npm i @cssnr/vitepress-plugin-contributors
- 添加数据 获得贡献者 脚本到您的
package.json。 。 。 .
{
"scripts": {
"get-contributors": "npx get-contributors user/repo",
"postinstall": "npm run get-contributors"
}
}
如果你们不添加 postinstall 您需要添加脚本 get-contributors 到你的建筑.
点击这里查看使用量 - 获得贡献者
显示帮助 : npx get-contributors -h
基本用途,所有贡献者不包括机器人用户.
npx get-contributors user/repo
限制为前20名贡献者,指定输出文件,并包括bot用户.
npx get-contributors user/repo -m 20 -f .vitepress/contributors.json -b
只有 user/repo 需要时间。 所有其他论点都是可选的.
| 参数旗 | 默认值 | 参数描述 |
|---|---|---|
-f编号 :--file | .vitepress/contributors.json | 相对于工程根输出文件 |
-m编号 :--max-users | 0 | 要获取的最大用户, 0 是无限的 |
-b编号 :--bots | - 说吧 | 将机器人用户纳入结果 |
-e编号 :--error | - 说吧 | 生成时丢出错误 |
-k编号 :--keys | login,avatar_url | 要保存到文件的密钥 |
-G编号 :--github | https://api.github.com | GitHub API URL( 用于企业) |
-F编号 :--forgejo | - 说吧 | Forgejo API URL(给吉特亚/科德伯格) |
说明: 此脚本向 GitHub API 提出一个请求, 每100名寄件者在寄存器( 或 max-users) (中文(简体) ).
因为如果你有很多贡献者(200+) 运行在背对背上,可能会被击中
页:1 GitHub 利率限制 对未经认证的请求,即每小时60个请求.
如果发生这种情况, 脚本将生成一个部分或空的投稿人, 这样可以继续开发 .
这不影响 GitHub 动作运行,这些运行被认证为 GTIHUB_TOKEN。 。 。 .
- 添加数据
contributors.json文件位置到您的.gitignore。 。 。 .
.vitepress/contributors.json
- 生成
contributors.json文档.
npm run get-contributors
或者,如果你没有添加 get-contributors 第2步的脚本.
npx get-contributors user/repo
- 导入您的组件
.vitepress/theme/index.js。 。 。 .
import DefaultTheme, { VPBadge } from 'vitepress/theme' // only if using VPBadge
import Contributors from '@cssnr/vitepress-plugin-contributors' // ADD this line
import '@cssnr/vitepress-plugin-contributors/style.css' // ADD this line
import contributors from '../contributors.json' // OPTIONAL - Global
export default {
...DefaultTheme,
enhanceApp({ app }) {
app.component('Badge', VPBadge) // only if using VPBadge
app.component('Contributors', Contributors) // ADD this line
app.config.globalProperties.$contributors = contributors // OPTIONAL - Global
},
}
Global - 如果你不确定这一点 使用量中,添加这些行以简单化.
VPBadge - 只有在您使用 VitePress 时才需要 徽标。 。 。 .
更多细节 贡献者.json 路径
注意,你可能需要修改 ../contributors.json 导入位置以匹配您的设置 .
如果您的 VitePress 配置目录位于 .vitepress 然后是默认输出
路径 .vitepress/contributors.json 从相对路径导入 ../contributors.json。 。 。 .
如果您没有导入 contributors 作为环球,此路径将相对于您导入的文件 .
见 使用量 更多细节.
- 最后,请使用 贡献者.vue 图标.
<Contributors :contributors="$contributors" />
见 使用量 更多细节...
使用量
要使用,只需添加 <Contributors> 标记到你的标记下的文件(或组件).
如果你添加的话 contributors 作为全球的组成部分,你只需要 <Contributors> 标签.
<Contributors :contributors="$contributors" />
否则,导入 contributors.json 添加一个 <Contributors> 标签.
<script setup>
import contributors from '../.vitepress/contributors.json'
</script>
<Contributors :contributors="contributors" />
这个 contributors.json 文件相对于您导入的文件.
见 选项 更多细节...
选项
只有 :contributors 需要参数,其他的都是可选的.
| 参数 | 默认 | 类型 | 参数说明 |
|---|---|---|---|
| : 贡献者 | 需求 | 阵列 | contributors.json 文件导入数据 |
| 最大用户 | - 说吧 | 字符串 | 要显示的用户数 |
| 标题 | - 说吧 | 字符串 | 可选标题文本 |
| 大小 | 64 | 字符串 | 用像素表示的图标大小 |
| 边距 | - 说吧 | 字符串 | CSS 比值 容器字符串 |
以所有论据为例.
<Contributors
:contributors="$contributors"
heading="VitePress Contributors"
max-users="98"
size="48"
margin="36px 0 96px"
/>
演示文稿
插件正在这些页面上运行 :
- https://django-files.github.io/ 互联网档案馆的存檔,存档日期2013-12-22 财务报告和审定财务报表 团队
- https://docker-deploy.cssnr.com/ 页面存档备份,存于互联网档案馆
- https://portainer-deploy.cssnr.com/ (中文(简体) )
如果你有现场演示, 告诉我们 我们把它放在这里...
支助
日志可以查看页面(Ctrl+Shift+I),点击控制台; Firefox:将调试日志,Chrome:将Verbose从水平降下.
如果您遇到任何问题或需要帮助,请做以下一项:
- 报告一个问题: https://github.com/cssnr/vitepress-plugin-controducers/ issues (中文(简体) )
- 讨论: https://github.com/csnr/vitepress-plugin-controducers/discussions/ classes/q-a) 互联网档案馆的存檔,存档日期2013-12-22
- 请求特性 : https://github.com/csnr/vitepress-plugin-controducers/issues/new?template=1-feature.yaml 互联网档案馆的存檔,存档日期2013-12-11
- 在Discord上和我们聊天: https://discord.gg/wXy6m2X8wy (中文(简体) )
更多虚拟新闻插件
捐款
欢迎所有捐款,包括: 错误报告, (中文(简体) ), 特性请求,或调取请求.
用于创建 PR 的指令 软件包 或者说 文档, (中文(简体) ), 见 捐款额。 。 。 .
请考虑捐款支持该项目和更多开放源码项目的发展.
关于目前项目访问的完整清单: https://cssnr.github.io/ (中文(简体) )
