-
Notifications
You must be signed in to change notification settings - Fork 0
/
PostList.tsx
84 lines (82 loc) · 1.89 KB
/
PostList.tsx
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from "react";
import { PostContent } from "../lib/posts";
import PostItem from "./PostItem";
import TagLink from "./TagLink";
import Pagination from "./Pagination";
import { TagContent } from "../lib/tags";
type Props = {
posts: PostContent[];
tags: TagContent[];
pagination: {
current: number;
pages: number;
};
};
export default function PostList({ posts, tags, pagination }: Props) {
return (
<div className={"container"}>
<div className={"posts"}>
<ul className={"post-list"}>
{posts.map((it, i) => (
<li key={i}>
<PostItem post={it} />
</li>
))}
</ul>
<Pagination
current={pagination.current}
pages={pagination.pages}
link={{
href: (page) => (page === 1 ? "/posts" : "/posts/page/[page]"),
as: (page) => (page === 1 ? null : "/posts/page/" + page),
}}
/>
</div>
<ul className={"categories"}>
{tags.map((it, i) => (
<li key={i}>
<TagLink tag={it} />
</li>
))}
</ul>
<style jsx>{`
.container {
display: flex;
margin: 0 auto;
max-width: 1200px;
width: 100%;
padding: 0 1.5rem;
}
ul {
margin: 0;
padding: 0;
}
li {
list-style: none;
}
.posts {
display: flex;
flex-direction: column;
flex: 1 1 auto;
}
.posts li {
margin-bottom: 1.5rem;
}
.post-list {
flex: 1 0 auto;
}
.categories {
display: none;
}
.categories li {
margin-bottom: 0.75em;
}
@media (min-width: 769px) {
.categories {
display: block;
}
}
`}</style>
</div>
);
}