diff --git a/.github/workflows/update-repositories.yml b/.github/workflows/update-repositories.yml deleted file mode 100644 index 18d6084..0000000 --- a/.github/workflows/update-repositories.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Update Repositories file - -on: - workflow_dispatch: - schedule: - - cron: "0 0 1 * *" - push: - paths: - - scripts/fetchRepositories.ts - -jobs: - update-repositories: - runs-on: ubuntu-latest - env: - OUTPUT_PATH: static/repositories.json - - steps: - - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v2 - - - name: Update repositories file - run: bun scripts/fetchRepositories.ts - - - name: Commit and push changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add $OUTPUT_PATH - git commit -m "Update $OUTPUT_PATH" || echo "No changes to commit" - git push diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 0079602..3fb442d 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -4,39 +4,49 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import Layout from '@theme/Layout'; import Heading from '@theme/Heading'; import styles from './index.module.css'; -import repositoriesData from '@site/static/repositories.json'; +import { useEffect, useState } from 'react'; interface Repository { - username: string; - repo: string; - name: string; - description: string; - downloads: number; - stars: number; - latestRelease: { - version: string; - date: string; - }; + repo: any; + latestRelease: any; } -function RepositoryCard({ repo }: { repo: Repository }) { +const repos = [ + { author: 'rehlds', repo: 'rehlds' }, + { author: 's1lentq', repo: 'ReGameDLL_CS' }, + { author: 's1lentq', repo: 'reapi' }, + // { author: 's1lentq', repo: 'metamod-r' }, + // { author: 's1lentq', repo: 'resemiclip' }, + // { author: 's1lentq', repo: 'reunion' }, + // { author: 's1lentq', repo: 'rechecker' }, + // { author: 's1lentq', repo: 'revoice' }, + // { author: 's1lentq', repo: 'refreelook' }, + // { author: 's1lentq', repo: 'localizebugfix' }, + // { author: 'WPMGPRoSToTeMa', repo: 'SafeNameAndChat' }, + // { author: 'rehlds', repo: 'relocalizebugfix' }, + // { author: 's1lentq', repo: 'hitboxtracker' }, +]; + +function RepositoryCard({ repoData }: { repoData: Repository }) { + const { repo, latestRelease } = repoData; + return (
- -

{repo.repo}

+
+

{repo.name}

-

{repo.description}

+

{repo.description || 'No description available.'}

- - Latest Release + Latest Release - - Downloads + Downloads {/* @@ -75,7 +85,28 @@ function HomepageHeader() { } export default function Home(): JSX.Element { - const repositories: Repository[] = repositoriesData; + const [repositories, setRepositories] = useState([]); + + useEffect(() => { + const fetchRepositories = async () => { + const repoDataPromises = repos.map(async ({ author, repo: repoName }) => { + const [repoResponse, releaseResponse] = await Promise.all([ + fetch(`https://api.github.com/repos/${author}/${repoName}`, { cache: 'force-cache' }), + fetch(`https://api.github.com/repos/${author}/${repoName}/releases/latest`, { cache: 'force-cache' }), + ]); + + const repo = await repoResponse.json(); + const latestRelease = releaseResponse.ok ? await releaseResponse.json() : { tag_name: 'N/A', published_at: 'N/A' }; + + return { repo, latestRelease }; + }); + + const allRepoData = await Promise.all(repoDataPromises); + setRepositories(allRepoData); + }; + + fetchRepositories(); + }, []); return (
{repositories.map((repo, index) => ( - + ))}
diff --git a/static/repositories.json b/static/repositories.json deleted file mode 100644 index 6f279a6..0000000 --- a/static/repositories.json +++ /dev/null @@ -1,38 +0,0 @@ -[ - { - "username": "rehlds", - "repo": "rehlds", - "name": "rehlds", - "description": "Reverse-engineered HLDS", - "downloads": 83, - "stars": 664, - "latestRelease": { - "version": "3.13.0.788", - "date": "2023-07-12T07:35:34Z" - } - }, - { - "username": "s1lentq", - "repo": "ReGameDLL_CS", - "name": "ReGameDLL_CS", - "description": ":hammer: Reverse-engineered gamedll (CS 1.6 / CZero)", - "downloads": 63, - "stars": 583, - "latestRelease": { - "version": "5.26.0.668", - "date": "2023-12-31T19:01:59Z" - } - }, - { - "username": "s1lentq", - "repo": "reapi", - "name": "reapi", - "description": "AMX Mod X module, using API regamedll & rehlds", - "downloads": 34, - "stars": 159, - "latestRelease": { - "version": "5.24.0.300", - "date": "2024-01-01T20:11:42Z" - } - } -] \ No newline at end of file