-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpages.tsx
200 lines (191 loc) · 5.15 KB
/
pages.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, JSX } from "https://deno.land/x/[email protected]/mod.ts";
import type { Owner, Repository } from "./types.ts";
export function HomePage() {
return (
<main>
<h1>Hello there.</h1>
<p>
Change <b>github.com</b> to <b>gre.deno.dev</b>{" "}
in the URL of a GitHub repository, and enjoy the simplicity.
</p>
<p>
Hey, why don't you check out the{" "}
<a href="https://gre.deno.dev/dcdunkan/gre">
source of this website
</a>{" "}
for a demonstration.
</p>
<h2>But Why?</h2>
<p>
GitHub's website is becoming laggier these days, at least for me. I
still use GitHub, but the website is a little bloated to browse code.
</p>
<p>
So, why not have a simple GitHub? Just to browse the code?
</p>
<p>Consider starring the repository if you found this useful.</p>
<p>Thank you :)</p>
</main>
);
}
const { format: fmtNo } = Intl.NumberFormat("en", { notation: "compact" });
export function UserPage(
{ user, repos, hasNext, hasPrev, readme, page }: {
user: Owner;
repos: Repository[];
readme?: string;
hasNext: boolean;
hasPrev: boolean;
page: number;
},
) {
return (
<main>
<div style="height: 40%">
<img
src={user.avatar_url}
style="border-radius: 50%"
width="50px"
/>
{user.name
? (
<div>
<h1>{user.name}</h1>
<h3>{user.login}</h3>
</div>
)
: <h1>{user.login}</h1>}
</div>
{user.bio ? <p>{user.bio}</p> : <></>}
{readme
? (
<details open>
<summary>README.md</summary>
<div dangerouslySetInnerHTML={{ __html: readme }}>
</div>
</details>
)
: <></>}
{user.public_repos > 0
? (
<div>
<h3>Repositories ({user.public_repos})</h3>
<div style="padding-bottom: 10px">
{hasPrev
? (
<a
class="no-color-link"
href={`/${user.login}?page=${page - 1}`}
>
Previous
</a>
)
: <></>}
{hasPrev && hasNext ? <span>{" | "}</span> : <></>}
{hasNext
? (
<a
class="no-color-link"
href={`/${user.login}?page=${page + 1}`}
>
Next
</a>
)
: <></>}
</div>
{...repos.map((repo) => {
return (
<div class="repo">
<a
class="no-color-link"
href={`/${repo.full_name}/${repo.default_branch}`}
>
<h3>{repo.name} {repo.fork ? "(Fork)" : <></>}</h3>
</a>
{repo.description ? <p>{repo.description}</p> : <></>}
<p>
{fmtNo(repo.stargazers_count)} stars |{" "}
{fmtNo(repo.forks_count)}{" "}
forks{repo.language ? ` | ${repo.language}` : ""}
</p>
</div>
);
})}
</div>
)
: <h2>{user.login} has no public repositories, yet.</h2>}
</main>
);
}
export function RepoPage(
{ readme, repo, branches, branch, treeList }: {
repo: Repository;
branch: string;
treeList: JSX.Element;
readme?: string;
branches: string[];
},
) {
return (
<main>
<b>
<a class="no-color-link" href={`/${repo.owner.login}`}>
{repo.owner.login}
</a>/
</b>
<h1>{repo.name}</h1>
{repo.fork
? (
<p>
<i>
Forked from{" "}
<a
href={`/${repo.parent?.full_name}/${repo.parent?.default_branch}`}
>
{repo.parent?.full_name}
</a>
</i>
</p>
)
: <></>}
{repo.description ? <p>{repo.description}</p> : <></>}
<p>
{fmtNo(repo.stargazers_count)} stars | {fmtNo(repo.forks_count)}{" "}
forks{repo.language ? ` | ${repo.language}` : ""}
</p>
<p>
On <b>{branch}</b> branch
</p>
<details>
<summary>Branches</summary>
<ul style="padding-left: 25px;">
{...branches.map((branch) => {
return (
<a
class="no-color-link"
href={`/${repo.owner.login}/${repo.name}/${branch}`}
>
<li>{branch}</li>
</a>
);
})}
</ul>
</details>
<details open>
<summary>Browse Code</summary>
{treeList}
</details>
{readme
? (
<details open>
<summary>README.md</summary>
<div dangerouslySetInnerHTML={{ __html: readme }}>
</div>
</details>
)
: <></>}
</main>
);
}