Nuxt Content 3 migration #12

Merged
eggy merged 81 commits from js into master 2022-08-10 18:38:39 -04:00
3 changed files with 48 additions and 25 deletions
Showing only changes of commit a41ead613c - Show all commits

View File

@ -2,40 +2,36 @@
import dayjs from "dayjs"; import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js"; import utc from "dayjs/plugin/utc.js";
import tz from "dayjs/plugin/timezone.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 FEED_URL = "https://api.github.com/users/potatoeggy/events";
const results = (await useFetch(FEED_URL)).data as Ref<GithubPushEvent[]>;
const imgUrl = ref(""); const imgUrl = ref("");
const href = ref("");
dayjs.extend(utc); for (const r of results.value) {
dayjs.extend(tz); if (r.type === "PushEvent") {
{
const { pending, data: results } = useLazyFetch(FEED_URL); const latest = r.payload.commits[0];
imgUrl.value = `https://opengraph.githubassets.com/hash/${r.repo.name}/commit/${latest.sha}`;
watch(results, (newResults) => { href.value = `https://github.com/${r.repo.name}/commit/${latest.sha}`;
for (const event of newResults) { }
break;
} }
}); }
</script> </script>
<template> <template>
<div class="prose dark:prose-invert"> <div class="prose dark:prose-invert">
<HomeStatBox <HomeStatBox
href="https://github.com" :href="href"
color="lightgray" color="lightgray"
title="Latest commit" title="Latest commit"
:clearstyles="true"
> >
<h2 class="m-0 mt-4 mb-1">Commit name</h2> <img class="m-0 w-full h-full" :src="imgUrl" v-if="imgUrl !== ''" />
<p class="text-sm text-gray-500 m-0">date · project</p>
<p class="excerpt text-gray-600 text-base m-0 mt-5">description</p>
<img :src="imgUrl" v-if="imgUrl !== ''" />
</HomeStatBox> </HomeStatBox>
</div> </div>
</template> </template>
<style scoped>
article p {
color: gray;
}
</style>

View File

@ -1,11 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Color } from "csstype"; import type { Color } from "csstype";
const { href, color = "pink" } = defineProps<{ const {
href,
color = "pink",
title,
clearstyles = false,
} = defineProps<{
href?: string; href?: string;
color?: Color; color?: Color;
title?: string; title?: string;
clearstyles?: boolean;
}>(); }>();
const padding = clearstyles ? "0" : "1rem";
</script> </script>
<template> <template>
@ -26,12 +34,13 @@ const { href, color = "pink" } = defineProps<{
* mobile * mobile
*/ */
width: 28rem; width: 28rem;
height: 16.25rem;
border: 0.5rem solid v-bind(color); border: 0.5rem solid v-bind(color);
border-radius: 0.5rem; border-radius: 0.5rem;
} }
.main-content { .main-content {
padding: 1rem; padding: v-bind(padding);
padding-top: 0; padding-top: 0;
} }

View File

@ -1,5 +1,23 @@
{ {
// https://v3.nuxtjs.org/concepts/typescript
"extends": "./.nuxt/tsconfig.json", "extends": "./.nuxt/tsconfig.json",
"compilerOptions": {"esModuleInterop": true} "compilerOptions": {
"esModuleInterop": true,
"jsx": "preserve",
"target": "esnext",
"module": "esnext",
"strict": true,
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"useDefineForClassFields": true,
"strictPropertyInitialization": true,
"resolveJsonModule": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"alwaysStrict": true
}
} }