Skip to content

Commit 1e8182b

Browse files
committed
feat: Convert GithubFeed to Astro component
Replaces the React component with an Astro component for better server-side rendering and performance.
1 parent 7807e2f commit 1e8182b

3 files changed

Lines changed: 42 additions & 102 deletions

File tree

src/components/GithubFeed.astro

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
export const prerender = false;
3+
import type { DisplayEvent } from "../pages/api/github";
4+
5+
const response = await fetch(new URL("/api/github", Astro.url));
6+
const events: DisplayEvent[] = await response.json();
7+
---
8+
9+
<div class="flex flex-col space-y-3">
10+
{events.map((item) => (
11+
<div class="group mx-2 rounded-xl bg-viola-50 p-4 transition-transform hover:scale-[1.01] sm:mx-4 sm:p-5">
12+
<a href={item.url} target="_blank" rel="noopener noreferrer" class="flex items-start space-x-3 sm:space-x-4">
13+
<img
14+
src={item.actor.avatar_url}
15+
alt={item.actor.login}
16+
class="h-8 w-8 shrink-0 rounded-full border-2 border-white shadow-sm sm:h-10 sm:w-10 bg-viola-100"
17+
/>
18+
19+
<div class="min-w-0 flex-1">
20+
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between">
21+
<p class="text-sm font-bold text-gray-900">
22+
{item.actor.login}
23+
<span class="mx-0.5 font-normal text-gray-500"> {item.verb} </span>
24+
<span class="text-viola-700">{item.object}</span>
25+
</p>
26+
<span class="mt-1 text-[10px] text-gray-400 sm:mt-0 sm:text-xs">{item.timestamp}</span>
27+
</div>
28+
29+
{item.description && (
30+
<div class="mt-2" style="mask-image: linear-gradient(to bottom, black 70%, transparent); -webkit-mask-image: linear-gradient(to bottom, black 70%, transparent);">
31+
<p class="line-clamp-3 whitespace-pre-wrap text-xs text-gray-600">{item.description}</p>
32+
</div>
33+
)}
34+
35+
<p class="mt-2 truncate text-[10px] font-semibold tracking-wide text-viola-700/80 sm:text-[11px]">{item.repo}</p>
36+
</div>
37+
</a>
38+
</div>
39+
))}
40+
</div>

src/components/GithubFeed.tsx

Lines changed: 0 additions & 100 deletions
This file was deleted.

src/pages/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import scheduliIcon from "../assets/schedule.svg";
55
import betterHudIcon from "../assets/betterhud.png";
66
import { Icon } from "astro-icon/components";
77
import DiscordStatus from "../components/DiscordStatus.tsx";
8-
import GithubFeed from "../components/GithubFeed.tsx";
8+
import GithubFeed from "../components/GithubFeed.astro";
99
---
1010

1111
<Layout title="dsns.dev" description="Check out what I do, and explore some of my projects.">
@@ -68,7 +68,7 @@ import GithubFeed from "../components/GithubFeed.tsx";
6868

6969
<div class="m-2 rounded-lg bg-viola-100 p-6 shadow-lg lg:p-8">
7070
<h2 class="mb-6 text-2xl font-bold">GitHub Feed</h2>
71-
<GithubFeed client:idle />
71+
<GithubFeed />
7272
</div>
7373
</div>
7474
</Layout>

0 commit comments

Comments
 (0)