diff --git a/lib/github.ts b/lib/github.ts index f5bd567..4ed77d0 100644 --- a/lib/github.ts +++ b/lib/github.ts @@ -70,3 +70,25 @@ async function fetchIssues(args: { } return GitHubIssueResponseSchema.parse(await resp.json()); } + +export async function fetchGitHubMembers(token: string, organization: string) { + const response = await fetch(`https://api.github.com/orgs/${organization}/members`, { + headers: { + Authorization: `token ${token}`, + Accept: 'application/vnd.github.v3+json', + }, + }); + + + if (!response.ok) { + throw new Error(`GitHub API request failed with status ${response.status}`); + } + + const members = await response.json(); + + return members.map((member: any) => ({ + fullName: member.login, + imageUrl: member.avatar_url, + profileUrl: member.html_url, + })); +} diff --git a/routes/index.tsx b/routes/index.tsx index 1138f01..999a1b6 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -1,18 +1,23 @@ -import { assert } from "$std/_util/asserts.ts"; -import { JSX } from "preact"; +import { assert } from '$std/_util/asserts.ts' +import { JSX } from 'preact' -export default function Home() { - const ghToken = Deno.env.get("GITHUB_TOKEN"); - assert(ghToken); +import { fetchGitHubMembers } from '../lib/github.ts' + +export default async function Home() { + const ghToken = Deno.env.get('GITHUB_TOKEN') + assert(ghToken) + + const org = 'devict' + + const contributors = await fetchGitHubMembers(ghToken, org) return (
- devICT is a volunteer-run community aiming to{" "} - educate, empower and connect{" "} - software developers and technologists in the{" "} - Wichita, KS area. + devICT is a volunteer-run community aiming to{' '} + educate, empower and connect software developers and + technologists in the Wichita, KS area.
@@ -26,25 +31,23 @@ export default function Home() {
{[
{
title: `Build Skills`,
- content:
- `Working on real-world projects exposes you to new technologies and best practices.`,
+ content: `Working on real-world projects exposes you to new technologies and best practices.`,
},
{
title: `Portfolio Building`,
- content:
- `Your contributions get recorded on GitHub, providing tangible proof of your skills.`,
+ content: `Your contributions get recorded on GitHub, providing tangible proof of your skills.`,
},
{
title: `Learning and Networking`,
- content:
- `Interacting with the community offers immense learning opportunities and widens your professional network.`,
+ content: `Interacting with the community offers immense learning opportunities and widens your professional network.`,
},
{
title: `Giving Back`,
- content:
- `By contributing, you help grow the local tech scene and create a richer environment for everyone involved.`,
+ content: `By contributing, you help grow the local tech scene and create a richer environment for everyone involved.`,
},
- ].map((card) =>
{content}
- ); + ) +} + +function Contributor({ fullName, imageUrl, profileUrl }: ContributorsProps) { + return ( + +{fullName}
+{fullName}
+ +{login}