From a41ead613cb0787eb0172c07a5c7f6ba275766f0 Mon Sep 17 00:00:00 2001 From: eggy Date: Tue, 9 Aug 2022 11:43:20 -0400 Subject: [PATCH] feat: add commit box --- components/CommitStatBox.vue | 38 ++++++++++++++++-------------------- components/HomeStatBox.vue | 13 ++++++++++-- tsconfig.json | 22 +++++++++++++++++++-- 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/components/CommitStatBox.vue b/components/CommitStatBox.vue index d7c5841..d4ef41a 100644 --- a/components/CommitStatBox.vue +++ b/components/CommitStatBox.vue @@ -2,40 +2,36 @@ import dayjs from "dayjs"; import utc from "dayjs/plugin/utc.js"; import tz from "dayjs/plugin/timezone.js"; -import type { BlogParsedContent } from "@/shared/types"; +import type { GithubPushEvent } from "@/shared/github"; +import type { Ref } from "vue"; const FEED_URL = "https://api.github.com/users/potatoeggy/events"; +const results = (await useFetch(FEED_URL)).data as Ref; + const imgUrl = ref(""); - -dayjs.extend(utc); -dayjs.extend(tz); - -const { pending, data: results } = useLazyFetch(FEED_URL); - -watch(results, (newResults) => { - for (const event of newResults) { +const href = ref(""); +for (const r of results.value) { + if (r.type === "PushEvent") { + { + const latest = r.payload.commits[0]; + imgUrl.value = `https://opengraph.githubassets.com/hash/${r.repo.name}/commit/${latest.sha}`; + href.value = `https://github.com/${r.repo.name}/commit/${latest.sha}`; + } + break; } -}); +} - - diff --git a/components/HomeStatBox.vue b/components/HomeStatBox.vue index 8c14c38..27baed7 100644 --- a/components/HomeStatBox.vue +++ b/components/HomeStatBox.vue @@ -1,11 +1,19 @@