-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
603 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<script setup lang="ts"> | ||
import { f7BlockTitle, f7Card, f7CardContent, f7CardHeader, f7SkeletonBlock } from 'framework7-vue' | ||
const { data: news, isLoading: newsIsLoading } = useNewsArticles() | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<f7BlockTitle large> | ||
What's Happening | ||
</f7BlockTitle> | ||
|
||
<div class="space-y-3"> | ||
<template v-if="newsIsLoading"> | ||
<f7SkeletonBlock v-for="n in 3" :key="n" class="rounded-md" effect="fade" height="10rem" /> | ||
</template> | ||
<template v-else-if="news"> | ||
<span v-if="news.length === 0" class="mt-4 opacity-80"> | ||
Nothing exciting is happening right now. | ||
<br> | ||
Check back later! | ||
</span> | ||
<f7Card v-for="article in news" :key="article.id" class="m-0!"> | ||
<f7CardHeader class="h-45 rounded-[16px]! overflow-hidden bg-center bg-contain relative" valign="bottom" :style="`background-image: url(${article.heroImageUrl})`"> | ||
<div class="absolute inset-0 bg-gradient-to-b from-transparent to-black/70" /> | ||
<span class="z-10"> | ||
{{ article.title }} | ||
</span> | ||
</f7CardHeader> | ||
<f7CardContent> | ||
{{ article.description }} | ||
</f7CardContent> | ||
</f7Card> | ||
</template> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useQuery } from '@tanstack/vue-query' | ||
import type { NewsArticle } from '~/shared/types' | ||
|
||
const queryKeyFactory = { | ||
newsArticles: ['newsArticles'], | ||
} | ||
|
||
export function useNewsArticles() { | ||
const firebaseCurrentUser = useCurrentUser() | ||
return useQuery({ | ||
queryKey: queryKeyFactory.newsArticles, | ||
queryFn: () => $api<NewsArticle[]>('/api/news'), | ||
enabled: computed(() => !!firebaseCurrentUser.value), // Only run when user exists | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default defineProtectedEventHandler((event) => { | ||
return event.context.database.query.news.findMany() | ||
}, { | ||
cache: { | ||
maxAge: 60, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE `news` ( | ||
`id` text PRIMARY KEY NOT NULL, | ||
`title` text NOT NULL, | ||
`description` text NOT NULL, | ||
`hero_image_alt` text NOT NULL, | ||
`hero_image_url` text NOT NULL, | ||
`cta_title` text NOT NULL, | ||
`cta_url` text NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.