import {useSSG} from 'nextra/ssg'
import { Cards, Card } from 'nextra/components'

export const getStaticProps = async ({params}) => {
    const githubRepo = await fetch(`https://api.github.com/repos/AprilNEA/ChatGPT-Admin-Web`)
        .then(res => res.json())
    const afdianPage = await fetch(`https://afdian.net/api/creator/get-top-sponsors?user_id=612f691e0f1611ee97c152540025c377`)
        .then(res => res.json())
    return {
        props: {
            // We add an `ssg` field to the page props,
            // which will be provided to the Nextra `useSSG` hook.
            ssg: {
                stars: githubRepo?.stargazers_count ?? 0,
                sponsors: afdianPage.data.list
            }
        },
        // The page will be considered as stale and regenerated every 60 seconds.
        revalidate: 60
    }
}

export const Sponsors = () => {
    const {sponsors} = useSSG()
    return <div style={{padding: "20px", display: "flex"}}>{sponsors.map((sponsor) => (
        <img
            key={sponsor.name}
            src={sponsor.avatar}
            alt={sponsor.name}
            style={{
                margin: "10px",
                borderRadius: "50%",
                width: "50px",
                height: "50px"
            }}/>
    ))}</div>
}

export const Stars = () => {
    // Get the data from SSG, and render it as a component.
    const {stars} = useSSG()
    return <strong>{stars}</strong>
}



# ChatGPT-Admin-Web

这是一个由 [ChatGPT-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web) 二次开发的项目。

<Cards>
  <Card title="快速开始" href="/quickstart" />
  <Card title="更新日志" href="/upgrade/log" />
</Cards>

## 捐赠

[GitHub Sponsor](https://github.com/sponsors/AprilNEA) | [爱发电](https://afdian.net/a/aprilnea)

ChatGPT-Admin-Web has <Stars /> stars on GitHub!

## 致谢

<Sponsors/>
