public/components/CommitStatBox.vue

38 lines
1.0 KiB
Vue
Raw Normal View History

2022-08-08 19:11:31 -04:00
<script setup lang="ts">
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
import tz from "dayjs/plugin/timezone.js";
2022-08-09 11:43:20 -04:00
import type { GithubPushEvent } from "@/shared/github";
import type { Ref } from "vue";
2022-08-08 19:11:31 -04:00
const FEED_URL = "https://api.github.com/users/potatoeggy/events";
2022-08-09 11:43:20 -04:00
const results = (await useFetch(FEED_URL)).data as Ref<GithubPushEvent[]>;
2022-08-08 19:11:31 -04:00
2022-08-09 11:43:20 -04:00
const imgUrl = ref("");
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;
2022-08-08 19:11:31 -04:00
}
2022-08-09 11:43:20 -04:00
}
2022-08-08 19:11:31 -04:00
</script>
<template>
2022-08-08 19:11:31 -04:00
<div class="prose dark:prose-invert">
<HomeStatBox
2022-08-09 11:43:20 -04:00
:href="href"
2022-08-08 19:11:31 -04:00
color="lightgray"
title="Latest commit"
2022-08-09 11:43:20 -04:00
:clearstyles="true"
2022-08-08 19:11:31 -04:00
>
2022-08-09 11:43:20 -04:00
<img class="m-0 w-full h-full" :src="imgUrl" v-if="imgUrl !== ''" />
2022-08-08 19:11:31 -04:00
</HomeStatBox>
</div>
</template>