-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): create post leaderboard + disable rate-limited buttons…
… + custom 404 page
- Loading branch information
Showing
11 changed files
with
307 additions
and
17 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
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,71 @@ | ||
--- | ||
import type { PostReactions } from "../../lib/appwrite/appwrite.server"; | ||
export type PostDataWithReactions = PostReactions & { | ||
href: string; | ||
title: string; | ||
}; | ||
export type Props = PostDataWithReactions & { rank: number }; | ||
const { title, href, likes, hearts, parties, poops, rank } = Astro.props; | ||
--- | ||
|
||
<div | ||
class={`not-prose flex gap-1 rounded-md border p-2 ${ | ||
rank === 1 | ||
? "shadow-lg dark:bg-white/5 shadow-primary-500/40 md:scale-105 mb-2" | ||
: "" | ||
}`} | ||
> | ||
<p class="mt-1"> | ||
<span | ||
class="tex-tenter mr-2 inline-flex h-12 w-12 items-center justify-center rounded-full bg-primary-500 text-primary-foreground" | ||
> | ||
{ | ||
rank < 4 ? ( | ||
<span class="text-3xl"> | ||
{rank === 1 | ||
? "🥇" | ||
: rank === 2 | ||
? "🥈" | ||
: rank === 3 | ||
? "🥉" | ||
: `#${rank}`} | ||
</span> | ||
) : ( | ||
<span>#{rank}</span> | ||
) | ||
} | ||
</span> | ||
</p> | ||
<div class="flex w-full flex-col gap-2"> | ||
<h2 class="m-0 text-lg"> | ||
<a class="text-link no-underline hover:underline" href={href}> | ||
{title} | ||
</a> | ||
</h2> | ||
<ul class="flex list-none justify-start gap-6"> | ||
<li> | ||
<span class="not-sr-only">👍</span> | ||
<span class="sr-only">likes: </span> | ||
<span class="ml-1">{likes}</span> | ||
</li> | ||
<li> | ||
<span class="not-sr-only">❤️</span> | ||
<span class="sr-only">hearts: </span> | ||
<span class="ml-1">{hearts}</span> | ||
</li> | ||
<li> | ||
<span class="not-sr-only">🎉</span> | ||
<span class="sr-only">parties: </span> | ||
<span class="ml-1">{parties}</span> | ||
</li> | ||
<li> | ||
<span class="not-sr-only">💩</span> | ||
<span class="sr-only">poops: </span> | ||
<span class="ml-1">{poops}</span> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> |
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
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,13 @@ | ||
--- | ||
import Layout from "../layouts/Page.astro"; | ||
--- | ||
|
||
<Layout | ||
title="Topics" | ||
description="An overview of all the various topics on our blog." | ||
> | ||
<h1>404 - not found :(</h1> | ||
<div class="not-prose"> | ||
<a class="btn" href="/blog">Go to the homepage</a> | ||
</div> | ||
</Layout> |
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,28 @@ | ||
import { type APIRoute } from "astro"; | ||
import { getPostReactionsRanked } from "../../lib/appwrite/appwrite.server"; | ||
|
||
export const prerender = false; | ||
|
||
export const GET: APIRoute = async (): Promise<Response> => { | ||
if (!import.meta.env.SECRET_APPWRITE_API_KEY) { | ||
return new Response(JSON.stringify({ error: "internal server error" }), { | ||
status: 500, | ||
}); | ||
} | ||
|
||
let postReactionsRanked = null; | ||
postReactionsRanked = await getPostReactionsRanked(); | ||
if (!postReactionsRanked) { | ||
return new Response(null, { | ||
status: 404, | ||
statusText: "Not found", | ||
}); | ||
} | ||
|
||
return new Response(JSON.stringify(postReactionsRanked), { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
}; |
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.