45 lines · 1.6 KB
1 ---
2 import Base from '../layouts/Base.astro';
3 import { apiGet } from '../lib/api';
4
5 let repos: any[] = [];
6 let error = '';
7 try {
8 repos = await apiGet('/api/repos');
9 } catch (e: any) {
10 error = e.message;
11 }
12 ---
13
14 <Base title="Explore">
15 <div class="container" style="padding-top: 24px;">
16 <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px;">
17 <h1 style="font-size: 1.5rem;">Explore repositories</h1>
18 <a href="/new" class="btn btn-primary">New repository</a>
19 </div>
20
21 {error && <div class="flash-error">{error}</div>}
22
23 <div class="repo-list">
24 {repos.length === 0 && !error && (
25 <p style="color: var(--text-muted); text-align: center; padding: 48px 0;">
26 No repositories yet. Create one to get started.
27 </p>
28 )}
29 {repos.map((repo: any) => (
30 <a href={`/${repo.owner_username}/${repo.name}`} class="repo-card card" style="display: block; margin-bottom: 8px;">
31 <div style="display: flex; align-items: baseline; gap: 8px;">
32 <span style="font-weight: 600; color: var(--text-link);">{repo.owner_username}/{repo.name}</span>
33 {repo.is_private ? (
34 <span style="font-size: 0.75rem; border: 1px solid var(--border); border-radius: 12px; padding: 0 8px; color: var(--text-muted);">Private</span>
35 ) : null}
36 </div>
37 {repo.description && (
38 <p style="color: var(--text-muted); font-size: 0.875rem; margin-top: 4px;">{repo.description}</p>
39 )}
40 </a>
41 ))}
42 </div>
43 </div>
44 </Base>
45