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