From dc6e36f13c8f94b148f6a3ec8378c66e5fd5034a Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 8 Feb 2024 14:29:38 -0500 Subject: Added personal repos; RSS icon on blog --- .vscode/settings.json | 30 ++++++++++++++++++ bun.lockb | Bin 283475 -> 283883 bytes package.json | 1 + src/components/GitHubProjects.jsx | 62 +++++++++++++++++++++----------------- src/pages/blog/index.astro | 15 +++++++++ src/pages/projects.astro | 9 +++--- 6 files changed, 84 insertions(+), 33 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..177e7da --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,30 @@ +{ + "frontMatter.taxonomy.contentTypes": [ + { + "name": "default", + "pageBundle": false, + "fields": [ + { + "title": "title", + "name": "title", + "type": "string" + }, + { + "title": "description", + "name": "description", + "type": "string" + }, + { + "title": "pubDate", + "name": "pubDate", + "type": "datetime" + }, + { + "title": "tags", + "name": "tags", + "type": "tags" + } + ] + } + ] +} \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index 06c4553..06e9abc 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 99f9738..fd1283f 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@astrojs/rss": "4.0.5", "@astrojs/vercel": "7.3.0", "@iconify-json/fa6-brands": "^1.1.18", + "@iconify-json/fa6-solid": "^1.1.20", "@supabase/supabase-js": "^2.39.3", "astro": "4.3.5", "astro-icon": "^1.1.0", 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()); ---
+
+ + + +
{allBlogPosts.map((post) => (
@@ -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; + } 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"; }) }
- -

AleeCorp/Alee Productions GitHub Repositories

- +

Andrew Lee GitHub Repositories

+ +

AleeCorp/Alee Productions GitHub Repositories

+