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

7
我想在我的Markdown中添加按钮,当按下时,让观看者fork、star或watch一个GitHub存储库。
我已经尝试将HTML添加到我的README.md文件中,但它没有起作用。
特别地,
<script async defer src="https://buttons.github.io/buttons.js></script>

似乎没有效果(只会显示链接)

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

还是有其他方法可以实现这个功能?

2个回答

8
如果您用按钮创建了一个图像文件,您可以直接将其合并到Markdown中。例如:
[![](https://s18955.pcdn.co/wp-content/uploads/2018/02/github.png)](https://github.com/user/repository/subscription)

要控制按钮的大小,您可能需要借鉴此答案中的html标签:在Markdown中更改图像大小

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

7

在Markdown文件中似乎无法使用非官方Github按钮。

但是,您可以使用不同的链接来访问这些操作(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)

如果有人知道一个链接来收藏一个repo,我会添加到这个答案中:)


2
据我所知,要启动一个项目需要使用PUT方法,因此无法从自述标记中完成:https://docs.github.com/en/rest/reference/activity#star-a-repository-for-the-authenticated-user - tuxErrante

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接