diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/GitHubProjects.jsx | 62 | ||||
| -rw-r--r-- | src/pages/blog/index.astro | 15 | ||||
| -rw-r--r-- | src/pages/projects.astro | 9 |
3 files changed, 53 insertions, 33 deletions
diff --git a/src/components/GitHubProjects.jsx b/src/components/GitHubProjects.jsx index b54dc9f..c4e805b 100644 --- a/src/components/GitHubProjects.jsx +++ b/src/components/GitHubProjects.jsx @@ -7,39 +7,45 @@ const GitHubProjects = ({ username, isOrganization }) => { const [currentPage, setCurrentPage] = useState(1); const reposPerPage = 10; - useEffect(() => { - const fetchRepos = async () => { - const baseUrl = 'https://api.github.com'; - const url = isOrganization - ? `${baseUrl}/orgs/${username}/repos` - : `${baseUrl}/users/${username}/repos`; - - try { - const response = await fetch(url); - const data = await response.json(); - - if (response.ok) { - if (Array.isArray(data)) { - setRepos(data.filter(repo => !repo.fork)); - } else { - console.error('Unexpected data format:', data); - setError('Unexpected data format'); - setRepos([]); + const fetchRepos = async (page = 1, allRepos = []) => { + const baseUrl = 'https://api.github.com'; + const url = isOrganization + ? `${baseUrl}/orgs/${username}/repos?page=${page}&per_page=100` + : `${baseUrl}/users/${username}/repos?page=${page}&per_page=100`; + + try { + const response = await fetch(url); + const data = await response.json(); + + if (response.ok) { + if (Array.isArray(data)) { + allRepos = allRepos.concat(data.filter(repo => !repo.fork)); + // If the data length is 100, there might be more repositories to fetch + if (data.length === 100) { + return fetchRepos(page + 1, allRepos); } } else { - console.error('API error:', data); - setError(data.message); + console.error('Unexpected data format:', data); + setError('Unexpected data format'); setRepos([]); } - } catch (err) { - console.error('Failed to fetch projects:', err); - setError(err.message); + } else { + console.error('API error:', data); + setError(data.message); setRepos([]); } - }; - - fetchRepos(); - }, [username, isOrganization]); // Don't forget to include dependencies + } catch (err) { + console.error('Failed to fetch projects:', err); + setError(err.message); + setRepos([]); + } + + return allRepos; + }; + + useEffect(() => { + fetchRepos().then(setRepos); + }, [username, isOrganization]); // Get current repos const indexOfLastRepo = currentPage * reposPerPage; @@ -72,4 +78,4 @@ const GitHubProjects = ({ username, isOrganization }) => { ); }; -export default GitHubProjects;
\ No newline at end of file +export default GitHubProjects; diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 5e4c619..0acaaee 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -3,11 +3,17 @@ import Page from "../../layouts/Page.astro"; import { getCollection } from "astro:content"; import {formatDate} from "../../util"; import "../../styles/cards.css"; +import {Icon} from "astro-icon/components"; const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf()); --- <Page title="Blog" description="Where I post can be anything!"> <main> + <div class="header"> + <a href="/blog/rss.xml"> + <Icon name="fa6-solid:square-rss" class="icon" /> + </a> + </div> <div class="grid"> {allBlogPosts.map((post) => ( <article class="card"> @@ -31,4 +37,13 @@ const allBlogPosts = (await getCollection('blog')).sort((a, b) => b.data.pubDate flex-direction: row; gap: 1em; } + + .header { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + gap: 0.5em; + font-size: 3em; + } </style> diff --git a/src/pages/projects.astro b/src/pages/projects.astro index c6fb19b..54cccde 100644 --- a/src/pages/projects.astro +++ b/src/pages/projects.astro @@ -26,11 +26,10 @@ import GitHubProjects from "../components/GitHubProjects"; }) } </div> - <!-- - <h2>Andrew Lee GitHub Repositories</h2> - <GitHubProjects client:visible username="Alee14" isOrganization=false />--> - <h2>AleeCorp/Alee Productions GitHub Repositories</h2> - <GitHubProjects client:visible username="alee14-projects" isOrganization=true /> + <h2><a href="https://github.com/Alee14" target="_blank">Andrew Lee GitHub Repositories</a></h2> + <GitHubProjects client:visible username="Alee14" /> + <h2><a href="https://github.com/alee14-projects" target="_blank">AleeCorp/Alee Productions GitHub Repositories</a></h2> + <GitHubProjects client:visible username="alee14-projects" isOrganization /> </main> </Page> <style> |
