1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-03 17:26:37 -04:00

v5: Revenge of the JavaScript 🦸 (#711)

Hugo ➡️ Next.js
This commit is contained in:
2021-12-30 08:18:41 -05:00
committed by GitHub
parent b7505fa260
commit 9979e1bf3f
577 changed files with 8019 additions and 11864 deletions

52
pages/projects.tsx Normal file
View File

@ -0,0 +1,52 @@
import useSWR from "swr";
import { fetcher } from "../lib/fetcher";
import Layout from "../components/Layout";
import Container from "../components/Container";
import PageTitle from "../components/page/PageTitle";
import RepositoryGrid from "../components/projects/RepositoryGrid";
import Loading from "../components/loading/Loading";
import { ProjectsIcon } from "../components/icons";
function Grid() {
// start fetching repos from API immediately
const { data, error } = useSWR("/api/projects/?sort=top&limit=12", fetcher);
if (error) {
return <div>error: {error.message}</div>;
}
// show spinning loading indicator if data isn't fetched yet
if (!data) {
return (
<div>
<Loading boxes={3} width={50} />
<style jsx>{`
div {
text-align: center;
margin: 2.5em auto;
}
`}</style>
</div>
);
}
// we have data!
return <RepositoryGrid repos={data} />;
}
export default function Projects() {
return (
<Layout>
<Container title="👨‍💻 Projects">
<PageTitle
title={
<>
<ProjectsIcon /> Projects
</>
}
/>
<Grid />
</Container>
</Layout>
);
}