|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
import z from "zod";
|
|
|
|
|
|
|
|
|
|
import { NextSeo } from "next-seo";
|
|
|
|
|
|
|
|
|
|
import { GetStaticProps, InferGetStaticPropsType, NextPage } from "next";
|
|
|
|
@ -7,6 +9,8 @@ import Layout from "@components/Layout";
|
|
|
|
|
import FeaturedRepositories from "@components/FeaturedRepositories";
|
|
|
|
|
import BestRepository from "@components/BestRepository";
|
|
|
|
|
|
|
|
|
|
import { RepositoryResponse } from "@models/responses";
|
|
|
|
|
|
|
|
|
|
import { fetchAvailability, fetchRepositories, fetchUser } from "@utils/fetch";
|
|
|
|
|
import { giteaUsername } from "@utils/config";
|
|
|
|
|
|
|
|
|
@ -17,10 +21,15 @@ export const getStaticProps: GetStaticProps = async () => {
|
|
|
|
|
|
|
|
|
|
const repositories = await fetchRepositories(user.id);
|
|
|
|
|
|
|
|
|
|
const bestRepository: z.infer<typeof RepositoryResponse> | undefined =
|
|
|
|
|
repositories.reduce((prev, current) =>
|
|
|
|
|
prev.stars_count > current.stars_count ? prev : current
|
|
|
|
|
);
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
|
|
|
|
isAvailable,
|
|
|
|
|
user,
|
|
|
|
|
bestRepository,
|
|
|
|
|
repositories
|
|
|
|
|
},
|
|
|
|
|
revalidate: 60 * 5
|
|
|
|
@ -30,14 +39,14 @@ export const getStaticProps: GetStaticProps = async () => {
|
|
|
|
|
const Index: NextPage = ({
|
|
|
|
|
repositories,
|
|
|
|
|
user,
|
|
|
|
|
bestRepository,
|
|
|
|
|
isAvailable
|
|
|
|
|
}: // bestRepository
|
|
|
|
|
InferGetStaticPropsType<typeof getStaticProps>) => (
|
|
|
|
|
}: InferGetStaticPropsType<typeof getStaticProps>) => (
|
|
|
|
|
<Layout>
|
|
|
|
|
<NextSeo title="Home" />
|
|
|
|
|
<User isAvailable={isAvailable} user={user} />
|
|
|
|
|
<FeaturedRepositories repositories={repositories} />
|
|
|
|
|
{/* <BestRepository repository={bestRepository} /> */}
|
|
|
|
|
<BestRepository repository={bestRepository} />
|
|
|
|
|
</Layout>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|