-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathproject.tsx
More file actions
55 lines (47 loc) · 1.72 KB
/
project.tsx
File metadata and controls
55 lines (47 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Loading } from 'idea-react';
import { GitRepository, RepositoryModel } from 'mobx-github';
import { observer } from 'mobx-react';
import { ScrollList } from 'mobx-restful-table';
import { cache, compose, errorLogger } from 'next-ssr-middleware';
import { FC, useContext } from 'react';
import { Col, Container, Row } from 'react-bootstrap';
import { GitCard } from '../components/Git/Card';
import { PageHead } from '../components/Layout/PageHead';
import { repositoryStore } from '../models/Repository';
import { I18nContext } from '../models/Translation';
export const getServerSideProps = compose(cache(), errorLogger, async () => {
const list = await new RepositoryModel('Open-Source-Bazaar').getList({
relation: ['languages'],
});
return { props: JSON.parse(JSON.stringify({ list })) };
});
const ProjectListPage: FC<{ list: GitRepository[] }> = observer(({ list }) => {
const i18n = useContext(I18nContext);
const { t } = i18n;
return (
<Container>
<PageHead title={t('open_source_projects')} />
<h1 className="my-4">{t('open_source_projects')}</h1>
{repositoryStore.downloading > 0 && <Loading />}
<ScrollList
translator={i18n}
store={repositoryStore}
filter={{ relation: ['languages'] }}
renderList={allItems => (
<Row as="ul" className="list-unstyled g-4" xs={1} sm={2}>
{allItems.map(
item =>
item.homepage && (
<Col key={item.id} as="li">
<GitCard className="h-100 shadow-sm" {...item} />
</Col>
),
)}
</Row>
)}
defaultData={list}
/>
</Container>
);
});
export default ProjectListPage;