html - 在网站中嵌入 Github 贡献图

标签 html api github github-api

有没有办法在 HTML5 中嵌入 Github 贡献图?

enter image description here

最佳答案

我写了一个 JavaScript 库来做到这一点:github-calendar .

Here是一个如何使用它的例子:

<!-- Prepare a container for your calendar. -->
<script
  src="https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.min.js"
>
</script>

<!-- Optionally, include the theme (if you don't want to struggle to write the CSS) -->
<link
  rel="stylesheet"
  href="https://cdn.rawgit.com/IonicaBizau/github-calendar/gh-pages/dist/github-calendar.css"
/>

<!-- Prepare a container for your calendar. -->
<div class="calendar">
    <!-- Loading stuff -->
    Loading the data just for you.
</div>

<script>
    new GitHubCalendar(".calendar", "your-username");
</script>

Here你可以看到它的实际效果:

基本上,由于我们需要跨域请求,因此我们需要一个代理。它向 GitHub 配置文件页面 ( github.com/<user> ) 发出请求,然后从那里带回所需的东西。

有关更多信息,请查看 documentation on GitHub .

关于html - 在网站中嵌入 Github 贡献图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34516592/

相关文章:

java - 有什么方法可以像谷歌或雅虎那样实时获取股票报价吗?

amazon-web-services - 静态站点的最佳图像托管解决方案?

git - 在 Github Pages 上将子目录设置为网站根目录

html - 形式低于所有其他李的李元素

html - 水平 Accordion 的 transform(270deg) 宽度和左侧 css 问题

java - 使用java api与USB驱动器交互

nginx+fcgiwrap错误 "fastcgi request record is too big"

javascript - 如何将(格式良好的)字符串变量分配给 &lt;input type ="date"/> 值

html - 我希望我的网页仅在台式机和平板电脑上缩小,而不是在移动设备上缩小

Python API Post请求URL返回错误