diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2024-02-08 14:29:38 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2024-02-08 14:29:38 -0500 |
| commit | dc6e36f13c8f94b148f6a3ec8378c66e5fd5034a (patch) | |
| tree | 8c8830a84d33306fc9e3f3c07baea1e4e4b82674 | |
| parent | f58a1d127577b07bd849df85afd5e574eaec3a35 (diff) | |
| download | personal-website-dc6e36f13c8f94b148f6a3ec8378c66e5fd5034a.tar.gz personal-website-dc6e36f13c8f94b148f6a3ec8378c66e5fd5034a.tar.bz2 personal-website-dc6e36f13c8f94b148f6a3ec8378c66e5fd5034a.zip | |
Added personal repos; RSS icon on blog
| -rw-r--r-- | .vscode/settings.json | 30 | ||||
| -rwxr-xr-x | bun.lockb | bin | 283475 -> 283883 bytes | |||
| -rw-r--r-- | package.json | 1 | ||||
| -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 |
6 files changed, 84 insertions, 33 deletions
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 Binary files differdiff --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()); --- <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> |
