Github个人首页美化指北

当你尝试去创建一个与你Github用户名相同的仓库时,会发现这是Github为你预留的特殊仓库,用来作为你的Github Profile,这个仓库就相当于一个可以显示在你Github个人页的README文件。

image20201013161715418.png

本文会帮助你美化你的Github Profile,让它展示更多有用的信息。

image20201013162238674.png

例如添加一个首页被访问次数的计数器,一个Github被Star与Commit的概览信息,以及各种技能标签,设备标签等。还可以利用wakatime显示你最近编码各类语言的使用时长,以及你最近Steam游戏游玩排行榜。

首页计数器

这个很容易实现,只需要一个统计资源请求的后台服务即可,有很多第三方的服务可以使用,并且我也自己搭建了一个,感兴趣的可以使用。

![](https://visitor-badge.glitch.me/badge?page_id=CasterWx.readme)

image20201013163054714.png

page_id后面替换为自己的Github用户名

![](http://antzuhl.cn:4000/get/@antzuhl.readme)

image20201013163125714.png

@后面替换为自己的Github用户名

Github信息概览

image20201013163452131.png

这个也是使用现有的服务,根据url来配置卡片信息。

![info](https://github-readme-stats.vercel.app/api?username=CasterWx&show_icons=true&count_private=true&hide=prs&theme=default_repocard)

url中username为你的Github用户名,theme为主题配置,支持的主题样式丰富。

dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula

技能&设备卡片

这是Github很多开源仓库都会使用的东西,其本质也是第三方服务后台动态生成的图片,类似下图

image20201013163646304.png

simpleicons提供了很多好看的icon,几乎可以找到所以的程序语言,设备,IDE,开源产品的icon。

image20201013163934515.png

我的配置

# linux卡片
[![](https://img.shields.io/badge/OS-Arch%20Linux-33aadd?style=flat-square&logo=arch-linux&logoColor=ffffff)](https://www.archlinux.org/)
# mac卡片
[![](https://img.shields.io/badge/macOS-Hackintosh-292e33?style=flat-square&logo=apple&logoColor=ffffff)](https://www.tonymacx86.com/)

# 手机设备
[![](https://img.shields.io/badge/Honor-V30-f5010c?style=flat-square&logo=huawei&logoColor=ffffff)](https://www.apple.com/)

# 程序语言
[![](https://img.shields.io/badge/-Java-007396?style=flat-square&logo=java&logoColor=ffffff)](https://reactjs.org/)

# 游戏
![](https://img.shields.io/badge/-Nintendo%20Switch-e60012?style=flat-square&logo=nintendo%20switch&logoColor=ffffff)
[![](https://img.shields.io/badge/Steam-171a21?style=flat-square&logo=steam&logoColor=ffffff)](https://steamcommunity.com/id/antzuhl)
编程&游戏时长统计

主要利用了Github Action的机制,触发定时任务去Wakatime平台拉取数据进行统计,而Wakatime平台提供了JetBrains全家桶、VsCode、Chrome的插件,用于统计用户的编程时长数据。

  1. 创建一个Github Gist https://gist.github.com/

  2. 新建一个拥有gist空间权限的Token,保存它 https://github.com/settings/tokens/new

  3. 创建一个WakaTime的账号 https://wakatime.com/signup

  4. 在你的WakaTime账号设置中选择公开你的编码活动 https://wakatime.com/settings/profile

image20201013165312401.png
  1. 在你WakaTime账户设置中创建Api-Key,并且复制它 https://wakatime.com/settings/api-key

  2. Fork这个仓库 https://github.com/matchai/waka-box

  3. 编辑.github/workflows/schedule.yml文件,将其中的GIST_ID设置为你创建的gist页面的url

  4. 在你仓库的安全设置中添加下面两个环境变量 Settings > Secrets

    • GH_TOKEN: 第2步的gist token
    • WAKATIME_API_KEY: 第7步中的wakatime Api-key

这样就算是完成了,如果你有Github Action知识,并且懂cron表达式,可以看看这个仓库的action脚本。

name: Update gist with WakaTime stats
on:
  schedule:
    - cron: "0 0 * * *"
jobs:
  update-gist:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - name: Update gist
        uses: matchai/waka-box@master
        env:
          GH_TOKEN: ${{ secrets.GH_TOKEN }}
          GIST_ID: 968220c97e8da1d047a9a480fa432e54
          WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}

其中cron就是该脚本执行的时间,每个小时的0秒0分,也就是指每小时执行一次。

你可以将这个gist的script文件添加到你的Github Profile中,用来在首页显示你的编码时间。

统计Steam游戏时间也是类似,不过没有Wakatime这样的平台去让我们拉取数据,但是我们可以直接去Steam拉取。

可以参考这个仓库

https://github.com/journey-ad/steam-go

代码片段,可以看到STEAM_API_KEY与STEAM_ID也是需要你设置到仓库环境变量中去的。

func main() {
	steamClient := steam.NewClient(os.Getenv("STEAM_API_KEY"), nil)
	steamID, _ := strconv.ParseUint(os.Getenv("STEAM_ID"), 10, 64)
	ctx := context.Background()
	params := &steam.GetOwnedGamesParams{
	....
	....

本质都是类似于爬虫,利用Github Action来达到触发的效果。

这样就算是完成了,还有更多玩法可以自己探索。

欢迎关注我的公众号: 肥宅与画家

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值