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 15:37:32 -04:00
|
|
|
import type { GithubCommit, GithubPushEvent } from "@/shared/github";
|
2022-08-09 11:43:20 -04:00
|
|
|
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 15:37:32 -04:00
|
|
|
const latestEvent = results.value.find(
|
|
|
|
(event) => event.type === "PushEvent"
|
|
|
|
) as GithubPushEvent;
|
|
|
|
const latestCommit = latestEvent.payload.commits[0];
|
|
|
|
const imgUrl = `https://opengraph.githubassets.com/hash/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
|
|
|
|
const href = `https://github.com/${latestEvent.repo.name}/commit/${latestCommit.sha}`;
|
|
|
|
|
|
|
|
const [title, description] = latestCommit.message.split("\n\n");
|
2022-08-08 19:11:31 -04:00
|
|
|
</script>
|
|
|
|
|
2022-08-08 17:49:35 -04:00
|
|
|
<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"
|
2022-08-09 16:25:23 -04:00
|
|
|
darkcolor="slategray"
|
2022-08-08 19:11:31 -04:00
|
|
|
title="Latest commit"
|
2022-08-09 11:43:20 -04:00
|
|
|
:clearstyles="true"
|
2022-08-08 19:11:31 -04:00
|
|
|
>
|
2022-08-09 15:37:32 -04:00
|
|
|
<img class="m-0 w-full h-full" :src="imgUrl" />
|
|
|
|
<!--
|
|
|
|
<div>
|
|
|
|
<h2>{{ title }}</h2>
|
|
|
|
<p v-if="description">{{ description }}</p>
|
|
|
|
</div>
|
|
|
|
-->
|
2022-08-08 19:11:31 -04:00
|
|
|
</HomeStatBox>
|
|
|
|
</div>
|
2022-08-08 17:49:35 -04:00
|
|
|
</template>
|