/ opencodehub / src / layouts / RepoLayout.astro
Swadhin Biswas Feature/ai code reviewer (#79) · 8/16/2026
cfd400d
58 lines · 1.5 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
56
57
58
---
import BaseLayout from "@/layouts/BaseLayout.astro";
import RepoHeader from "@/components/repo/RepoHeader.astro";
import { getRepoAndUser } from "@/lib/auth";

interface Props {
    title: string;
    activeTab:
        | "code"
        | "issues"
        | "pulls"
        | "actions"
        | "projects"
        | "wiki"
        | "security"
        | "insights"
        | "settings";
}

const { title, activeTab } = Astro.props;
const { owner, repo } = Astro.params;

const repoInfo = await getRepoAndUser(Astro.request, owner!, repo!);

if (!repoInfo) {
    return Astro.redirect("/404");
}

const { repository } = repoInfo;

// Org-owned repos have no user `owner` relation (ownerId = org id)
const repoOwnerName = (repository as any).owner?.username ?? owner!;

const repoData = {
    owner: repoOwnerName,
    name: repository.name,
    description: repository.description,
    visibility: repository.visibility,
    topics: repository.topics ? JSON.parse(repository.topics) : [],
    watchers: repository.watchCount,
    forks: repository.forkCount,
    stars: repository.starCount,
    openIssueCount: repository.openIssueCount || 0, // Should fetch real count if needed
    openPrCount: repository.openPrCount || 0,
    website: repository.website,
    license: repository.licenseType,
    updatedAt: repository.updatedAt,
};
---

<BaseLayout title={title}>
    <div class="container py-6">
        <RepoHeader repo={repoData} activeTab={activeTab} />
        <slot />
    </div>
    
</BaseLayout>