Fixed overflow for mobile, loading in gh projects

This commit is contained in:
Andrew Lee 2024-02-08 21:41:36 -05:00
parent dc6e36f13c
commit c1b2794611
Signed by: andrew
SSH key fingerprint: SHA256:bbGg1DYG5CuKl2jo1DqzvUsaTeyvhM3tjCsej5lYMg4
9 changed files with 100 additions and 47 deletions

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1 @@
{}

46
.vscode/settings.json vendored
View file

@ -1,30 +1,24 @@
{ {
"frontMatter.taxonomy.contentTypes": [ "[markdown]": {
"editor.fontSize": 14,
"editor.lineHeight": 26,
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 64,
"editor.lineNumbers": "off",
"editor.quickSuggestions": false,
"editor.minimap.enabled": false
},
"frontMatter.content.publicFolder": "public",
"frontMatter.content.pageFolders": [
{ {
"name": "default", "title": "blog",
"pageBundle": false, "path": "[[workspace]]/src/content/blog"
"fields": [ },
{ {
"title": "title", "title": "pages",
"name": "title", "path": "[[workspace]]/src/pages"
"type": "string"
},
{
"title": "description",
"name": "description",
"type": "string"
},
{
"title": "pubDate",
"name": "pubDate",
"type": "datetime"
},
{
"title": "tags",
"name": "tags",
"type": "tags"
}
]
} }
] ],
"frontMatter.framework.id": "astro",
"frontMatter.preview.host": "http://localhost:4321"
} }

46
frontmatter.json Normal file
View file

@ -0,0 +1,46 @@
{
"$schema": "https://frontmatter.codes/frontmatter.schema.json",
"frontMatter.framework.id": "astro",
"frontMatter.preview.host": "http://localhost:4321",
"frontMatter.content.publicFolder": "public",
"frontMatter.content.pageFolders": [
{
"title": "blog",
"path": "[[workspace]]/src/content/blog"
}
],
"frontMatter.taxonomy.contentTypes": [
{
"name": "blog",
"previewPath": "'blog'",
"pageBundle": false,
"clearEmpty": true,
"fields": [
{
"name": "title",
"type": "string",
"single": true,
"required": true
},
{
"name": "description",
"type": "string",
"single": true,
"required": true
},
{
"name": "pubDate",
"type": "datetime",
"default": "{{now}}",
"required": true
},
{
"name": "tags",
"type": "tags",
"required": true
}
]
}
],
"frontMatter.framework.startCommand": "bun run dev"
}

View file

@ -4,6 +4,7 @@ import { useState, useEffect } from 'preact/hooks';
const GitHubProjects = ({ username, isOrganization }) => { const GitHubProjects = ({ username, isOrganization }) => {
const [repos, setRepos] = useState([]); const [repos, setRepos] = useState([]);
const [error, setError] = useState(null); const [error, setError] = useState(null);
const [isLoading, setIsLoading] = useState(true);
const [currentPage, setCurrentPage] = useState(1); const [currentPage, setCurrentPage] = useState(1);
const reposPerPage = 10; const reposPerPage = 10;
@ -40,6 +41,7 @@ const GitHubProjects = ({ username, isOrganization }) => {
setRepos([]); setRepos([]);
} }
setIsLoading(false);
return allRepos; return allRepos;
}; };
@ -47,34 +49,38 @@ const GitHubProjects = ({ username, isOrganization }) => {
fetchRepos().then(setRepos); fetchRepos().then(setRepos);
}, [username, isOrganization]); }, [username, isOrganization]);
// Get current repos
const indexOfLastRepo = currentPage * reposPerPage; const indexOfLastRepo = currentPage * reposPerPage;
const indexOfFirstRepo = indexOfLastRepo - reposPerPage; const indexOfFirstRepo = indexOfLastRepo - reposPerPage;
const currentRepos = repos.slice(indexOfFirstRepo, indexOfLastRepo); const currentRepos = repos.slice(indexOfFirstRepo, indexOfLastRepo);
// Change page
const nextPage = () => setCurrentPage(currentPage + 1); const nextPage = () => setCurrentPage(currentPage + 1);
const prevPage = () => setCurrentPage(currentPage - 1); const prevPage = () => setCurrentPage(currentPage - 1);
return ( return (
<div>
{error && <div class="error">{error}</div>}
<div class="grid">
{currentRepos.map((repo) => (
<article class="card">
<h1>{repo.name}</h1>
<p>{repo.description}</p>
<div class="row">
<a href={repo.html_url} target="_blank">Repository</a>
</div>
</article>
))}
</div>
<div> <div>
{currentPage > 1 && <button class="button margin" onClick={prevPage}>Previous</button>} {isLoading ? (
{currentPage < Math.ceil(repos.length / reposPerPage) && <button class="button margin" onClick={nextPage}>Next</button>} <div>Loading...</div>
) : (
<>
{error && <div class="error">{error}</div>}
<div class="grid">
{currentRepos.map((repo) => (
<article class="card">
<h1>{repo.name}</h1>
<p>{repo.description}</p>
<div class="row">
<a href={repo.html_url} target="_blank">Repository</a>
</div>
</article>
))}
</div>
<div>
{currentPage > 1 && <button class="button margin" onClick={prevPage}>Previous</button>}
{currentPage < Math.ceil(repos.length / reposPerPage) && <button class="button margin" onClick={nextPage}>Next</button>}
</div>
</>
)}
</div> </div>
</div>
); );
}; };

View file

@ -39,7 +39,7 @@
}, },
{ {
"name": "Snug Cup", "name": "Snug Cup",
"description": "Snug Cup was a school project that I made with my classmates back in 2021.", "description": "A school project that I made with my classmates in high school.",
"links": [ "links": [
{ {
"name": "Website", "name": "Website",

View file

@ -43,7 +43,7 @@ const date = new Date();
<slot /> <slot />
<footer> <footer>
<p>Made with {Astro.generator} and Hosted on Vercel</p> <p>Made with {Astro.generator} and Hosted on Vercel</p>
<p>Copyright &copy; {date.getFullYear()} Andrew Lee. <a href="https://github.com/Alee14/personal-website">View source code.</a></p> <p>Copyright &copy; {date.getFullYear()} Andrew Lee. <a href="https://github.com/Alee14/personal-website" target="_blank">View source code.</a></p>
</footer> </footer>
</div> </div>
</body> </body>

View file

@ -69,7 +69,7 @@ import '../../styles/cards.css';
<li>Zeon OS 0.2</li> <li>Zeon OS 0.2</li>
</ul> </ul>
</div> </div>
<div> <div class="checksum">
<p>MD5: d14f7bfd17fa66ada3d48020deffcce0</p> <p>MD5: d14f7bfd17fa66ada3d48020deffcce0</p>
<p>SHA512: b481d73f839c2ad99b6d6502d5735f416fbcc38dbac811c3d939845d319fecf8b15dd4ff1728ed96abe19077be19527df3692c54751bb81c201e58934d016527</p> <p>SHA512: b481d73f839c2ad99b6d6502d5735f416fbcc38dbac811c3d939845d319fecf8b15dd4ff1728ed96abe19077be19527df3692c54751bb81c201e58934d016527</p>
<p>SHA256: c7ad3f799f14e610f8931f87e2612385ec39e2662308e7005e10715f9e94c6a0</p> <p>SHA256: c7ad3f799f14e610f8931f87e2612385ec39e2662308e7005e10715f9e94c6a0</p>
@ -101,4 +101,8 @@ import '../../styles/cards.css';
a { a {
font-size: 1.5em; font-size: 1.5em;
} }
.checksum {
overflow-wrap: break-word;
}
</style> </style>