From 9484692dfaf8dcc2a10b8dda6e09dbeb5b0f5c42 Mon Sep 17 00:00:00 2001 From: eggy Date: Wed, 10 Aug 2022 10:56:49 -0400 Subject: [PATCH] fix: statcard without colours --- components/BlogStatBox.vue | 3 +++ components/CommitStatBox.vue | 23 +++++++++++++---------- components/HomeStatBox.vue | 26 ++++++++++++++++++-------- pages/index.vue | 4 +++- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/components/BlogStatBox.vue b/components/BlogStatBox.vue index f894e01..8be0491 100644 --- a/components/BlogStatBox.vue +++ b/components/BlogStatBox.vue @@ -7,6 +7,9 @@ import type { BlogParsedContent } from "@/shared/types"; dayjs.extend(utc); dayjs.extend(tz); +// TODO: make queryContent async so it doesn't delay +// execution of the template + const docs = await queryContent("/blog") .sort({ date: 1 }) .where({ _draft: false }) diff --git a/components/CommitStatBox.vue b/components/CommitStatBox.vue index b89f0ef..0e7d854 100644 --- a/components/CommitStatBox.vue +++ b/components/CommitStatBox.vue @@ -6,17 +6,19 @@ import type { GithubCommit, GithubPushEvent } from "@/shared/github"; import type { Ref } from "vue"; const FEED_URL = "https://api.github.com/users/potatoeggy/events"; +const imgUrl = ref(""); +const href = ref(""); -const results = (await useFetch(FEED_URL)).data as Ref; - -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"); +onMounted(async () => { + const results = (await useFetch(FEED_URL, { initialCache: false })) + .data as Ref; + const latestEvent = results.value.find( + (event) => event.type === "PushEvent" + ) as GithubPushEvent; + const latestCommit = latestEvent.payload.commits[0]; + imgUrl.value = `https://opengraph.githubassets.com/hash/${latestEvent.repo.name}/commit/${latestCommit.sha}`; + href.value = `https://github.com/${latestEvent.repo.name}/commit/${latestCommit.sha}`; +}); diff --git a/components/HomeStatBox.vue b/components/HomeStatBox.vue index 335c014..5a3aed2 100644 --- a/components/HomeStatBox.vue +++ b/components/HomeStatBox.vue @@ -22,12 +22,22 @@ const { }>(); const padding = clearstyles ? "0" : "1rem"; -const height = forceheight ?? "auto"; +const height = forceheight ?? "100%"; + +// v-bind DOES NOT WORK on initial render +// so unfortunately we have to use the old way + +const cssVars = { + "--padding": padding, + "--height": height, + "--color": color, + "--darkcolor": darkcolor, +};