mirror of
https://github.com/rehlds/rehlds.github.io.git
synced 2025-02-06 02:10:29 +03:00
Rework repositories info getting by realtime GitHub API (#9)
Co-authored-by: Xelson <Xelson@users.noreply.github.com>
This commit is contained in:
parent
c16cb552fa
commit
f04d5fe914
30
.github/workflows/update-repositories.yml
vendored
30
.github/workflows/update-repositories.yml
vendored
@ -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
|
@ -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 (
|
||||
<div className={clsx(styles.repoCard, 'card')}>
|
||||
<a href={`https://github.com/${repo.username}/${repo.repo}`} target="_blank" rel="noopener noreferrer">
|
||||
<h2 className="card__title">{repo.repo}</h2>
|
||||
<a href={repo.html_url} target="_blank" rel="noopener noreferrer">
|
||||
<h2 className="card__title">{repo.name}</h2>
|
||||
</a>
|
||||
<p className={styles.shortDesc}>{repo.description}</p>
|
||||
<p className={styles.shortDesc}>{repo.description || 'No description available.'}</p>
|
||||
<div className={styles.badges}>
|
||||
<a href={`https://github.com/${repo.username}/${repo.repo}/releases`} target="_blank" rel="noopener noreferrer">
|
||||
<img
|
||||
src={`https://img.shields.io/github/v/release/${repo.username}/${repo.repo}?include_prereleases&style=for-the-badge`}
|
||||
alt="Latest Release"
|
||||
<a href={`${repo.html_url}/releases`} target="_blank" rel="noopener noreferrer">
|
||||
<img
|
||||
src={`https://img.shields.io/github/v/release/${repo.owner.login}/${repo.name}?include_prereleases&style=for-the-badge`}
|
||||
alt="Latest Release"
|
||||
/>
|
||||
</a>
|
||||
<a href={`https://github.com/${repo.username}/${repo.repo}/releases`} target="_blank" rel="noopener noreferrer">
|
||||
<img
|
||||
src={`https://img.shields.io/github/downloads/${repo.username}/${repo.repo}/total?style=for-the-badge`}
|
||||
alt="Downloads"
|
||||
<a href={`${repo.html_url}/releases`} target="_blank" rel="noopener noreferrer">
|
||||
<img
|
||||
src={`https://img.shields.io/github/downloads/${repo.owner.login}/${repo.name}/total?style=for-the-badge`}
|
||||
alt="Downloads"
|
||||
/>
|
||||
</a>
|
||||
{/* <a href={`https://github.com/${repo.username}/${repo.repo}/stargazers`} target="_blank" rel="noopener noreferrer">
|
||||
@ -75,7 +85,28 @@ function HomepageHeader() {
|
||||
}
|
||||
|
||||
export default function Home(): JSX.Element {
|
||||
const repositories: Repository[] = repositoriesData;
|
||||
const [repositories, setRepositories] = useState<Repository[]>([]);
|
||||
|
||||
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 (
|
||||
<Layout
|
||||
@ -84,7 +115,7 @@ export default function Home(): JSX.Element {
|
||||
<main>
|
||||
<div className={styles.repoList}>
|
||||
{repositories.map((repo, index) => (
|
||||
<RepositoryCard key={index} repo={repo} />
|
||||
<RepositoryCard key={index} repoData={repo} />
|
||||
))}
|
||||
</div>
|
||||
</main>
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user