如何在 Markdown (README.md) 中使用 Github 按钮

fin*_*las 3 html javascript markdown github

我想在我的降价中添加按钮,当按下时,让查看器分叉、加星或观看github 存储库。

我已经尝试将 html 添加到我的 README.md 中,但它不起作用。

尤其

<script async defer src="https://buttons.github.io/buttons.js></script>
Run Code Online (Sandbox Code Playgroud)

似乎不起作用(它只显示链接)

有没有办法在降价 (.md) 文件中使用 Github 按钮 ( https://buttons.github.io )?

或者有其他方法来实现这一点吗?

小智 7

非官方的好像不太可能用在 Markdown 文件中

但是,您可以使用不同的链接来访问这些操作(Markdown 样式):

  • 叉:

[fork my repository](https://github.com/user/repository/fork)

  • 观看/关注:

[watch this repo](https://github.com/user/repository/subscription)

  • 创建问题:

[create issue](https://github.com/user/repository/issues/new)

如果有人知道给仓库加注星标的链接,我会将其添加到此答案中:)

  • 据我所知,要为项目加注星标需要 PUT,因此无法从自述文件降价中完成:https://docs.github.com/en/rest/reference/activity#star-a-repository-for-the-经过身份验证的用户 (2认同)

Ari*_*eld 5

如果您使用按钮创建了图像文件,则可以将其直接合并到 Markdown 中。

例如:

[![](https://s18955.pcdn.co/wp-content/uploads/2018/02/github.png)](https://github.com/user/repository/subscription)
Run Code Online (Sandbox Code Playgroud)

要控制按钮的大小,您可能需要合并从此答案中借用的 html更改 Markdown 中的图像大小

[<img src="https://s18955.pcdn.co/wp-content/uploads/2018/02/github.png" width="25"/>](https://github.com/user/repository/subscription)
Run Code Online (Sandbox Code Playgroud)