BlogにGitHubの草を生やす

Dev/Blog
GitHub
Vue.js
Blog

更新日時 : 2022/05/29 15:51
投稿日時 : 2020/03/31 09:39

プロフィールページがテキストだけで、何か画像を表示したいと思ったので、GitHubのプロフィールページにある、いわゆる芝生を表示することにした。
芝生はいわゆる日本の愛称みたいなもので、 Contributions という「過去一年間でこれだけ活動したよ」を可視化する機能である。公式サイトはこちら

下記のサイトでブログのサイドパーツに表示する例があったので、参考にした。

https://blog.jnito.com/entry/2018/11/04/200916

芝生を画像化するWebサービスが紹介されていたので、Vueコンポーネントを作成し、トップページに追加した。
表示される画像は下記の感じである。

shiba

GlassGraph.vue

<template>
  <v-container fluid>
    <v-row>
      <v-col>
        <a :href="this.githubLink" target="_blank" rel="noopener">
          <v-img v-bind:src="this.imageLink"></v-img>
        </a>
      </v-col>
    </v-row>
  </v-container>
</template>
<script lang="ts">
export default {
  props: {
    githubId: {
      type: String,
      required: true,
      default: "vagivagi"
    }
  },
  data: function() {
    return {
      imageLink: {
        type: String,
        required: true
      },
      githubLink: {
        type: String,
        required: true
      }
    };
  },
  created: function() {
    this.imageLink =
      "https://grass-graph.moshimo.works/images/" + this.githubId + ".png";
    this.githubLink = "https://github.com/" + this.githubId;
  }
};
</script>