diff --git a/components/PersonCard.tsx b/components/PersonCard.tsx new file mode 100644 index 0000000..57a0fac --- /dev/null +++ b/components/PersonCard.tsx @@ -0,0 +1,45 @@ +import { FC } from 'react'; +import { Badge, Card, Col } from 'react-bootstrap'; + +export type PersonCardProps = { + avatar: string; + name: string; + link?: string; + position?: string; + count?: number; +}; + +export const PersonCard: FC = ({ + avatar, + name, + link, + position, + count, +}) => ( + + + {count != null && ( + + {count} + + )} + + + + {name} + + {position} + + + +); diff --git a/components/SectionTitle.tsx b/components/SectionTitle.tsx new file mode 100644 index 0000000..a7e0d92 --- /dev/null +++ b/components/SectionTitle.tsx @@ -0,0 +1,19 @@ +import { FC, HTMLAttributes, PropsWithChildren } from 'react'; +import { Badge } from 'react-bootstrap'; + +export type SectionTitleProps = PropsWithChildren< + HTMLAttributes & { count?: number } +>; + +export const SectionTitle: FC = ({ + className = '', + count, + children, +}) => ( +

+ {children} + + {count} + +

+); diff --git a/components/data.ts b/components/data.ts index 4e0d0be..cd4c9e9 100644 --- a/components/data.ts +++ b/components/data.ts @@ -31,4 +31,8 @@ export const MainRoutes: () => Link[] = () => [ title: t('source_code'), path: 'https://github.com/kaiyuanshe/OSS-toolbox', }, + { + title: t('volunteer'), + path: '/volunteer', + }, ]; diff --git a/pages/volunteer.tsx b/pages/volunteer.tsx new file mode 100644 index 0000000..6e5a59e --- /dev/null +++ b/pages/volunteer.tsx @@ -0,0 +1,51 @@ +import { Contributor } from 'mobx-github'; +import { InferGetServerSidePropsType } from 'next'; +import { cache, compose, errorLogger } from 'next-ssr-middleware'; +import { FC } from 'react'; +import { Container, Row } from 'react-bootstrap'; + +import { PageHead } from '../components/PageHead'; +import { PersonCard } from '../components/PersonCard'; +import { SectionTitle } from '../components/SectionTitle'; +import { repositoryStore } from '../models/Repository'; +import { i18n } from '../models/Translation'; + +const { t } = i18n; + +export const getServerSideProps = compose(cache(), errorLogger, async () => { + const contributors: Contributor[] = + await repositoryStore.getAllContributors(); + return { props: { contributors } }; +}); + +const Organizer: FC> = ({ + contributors, +}) => ( + + +

{t('volunteer')}

+ + + {t('online_volunteer')} + + + {contributors.map(({ login, html_url, contributions }) => ( + + ))} + +
+); + +export default Organizer; diff --git a/translation/en-US.ts b/translation/en-US.ts index 150db61..5ef2d12 100644 --- a/translation/en-US.ts +++ b/translation/en-US.ts @@ -123,4 +123,8 @@ export default { select_compatible_browser: 'select Compatible Browser', select_features: 'select features', search_feature: 'search Feature', + + //volunteer page + volunteer: 'volunteer', + online_volunteer: 'online volunteer', } as const; diff --git a/translation/zh-CN.ts b/translation/zh-CN.ts index d64876e..5e76dd9 100644 --- a/translation/zh-CN.ts +++ b/translation/zh-CN.ts @@ -120,4 +120,8 @@ export default { select_compatible_browser: '选择兼容浏览器', select_features: '选择特性', search_feature: '搜索特性', + + //volunteer page + volunteer: '志愿者', + online_volunteer: '线上志愿者', } as const; diff --git a/translation/zh-TW.ts b/translation/zh-TW.ts index 1e6ab02..adaf0e7 100644 --- a/translation/zh-TW.ts +++ b/translation/zh-TW.ts @@ -120,4 +120,8 @@ export default { select_compatible_browser: '選擇相容瀏覽器', select_features: '選擇特性', search_feature: '搜尋特性', + + //volunteer page + volunteer: '志願者', + online_volunteer: '線上志願者', } as const;