Skip to content

Commit e8be143

Browse files
authored
Merge pull request #55 from daeisbae/54-modularize-into-components-to-use-react-suspense-for-repository-summarization-view-page
Modularize the components to show loading state (#54) - Repository summarization view page
2 parents 264f573 + 7c4a62c commit e8be143

File tree

2 files changed

+42
-22
lines changed

2 files changed

+42
-22
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { RepoCard } from '@/components/RepoCard'
2+
import { FetchRepoService } from '@/service/get-db'
3+
import { MarkdownContent } from '@/components/MarkdownContent'
4+
import { notFound } from 'next/navigation'
5+
import { formatToMarkdown } from '@/app/[ownerSlug]/[repoSlug]/formatter'
6+
7+
interface RepositorySummarizationContentProps {
8+
owner: string
9+
repo: string
10+
}
11+
12+
export default async function RepositorySummarizationContent({
13+
owner,
14+
repo,
15+
}: RepositorySummarizationContentProps) {
16+
const fetchRepoService = new FetchRepoService()
17+
const repoDetails = await fetchRepoService.getFullRepositoryTree(
18+
owner,
19+
repo
20+
)
21+
22+
if (!repoDetails) {
23+
notFound()
24+
}
25+
26+
return (
27+
<>
28+
<div className="flex-1">
29+
<MarkdownContent content={formatToMarkdown(repoDetails)} />
30+
</div>
31+
<div className="w-[300px]">
32+
<RepoCard repoInfo={repoDetails.repository} />
33+
</div>
34+
</>
35+
)
36+
}
Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,26 @@
11
import { JSX, Suspense } from 'react'
2-
import { RepoCard } from '@/components/RepoCard'
3-
import { FetchRepoService } from '@/service/get-db'
4-
import { MarkdownContent } from '@/components/MarkdownContent'
5-
import { notFound } from 'next/navigation'
6-
import { formatToMarkdown } from '@/app/[ownerSlug]/[repoSlug]/formatter'
72
import Loading from '@/app/[ownerSlug]/[repoSlug]/loading'
3+
import RepositorySummarizationContent from '@/app/[ownerSlug]/[repoSlug]/contents';
84

9-
// Define the correct page props type for Next.js 13+
105
interface PageProps {
116
params: Promise<{ ownerSlug: string; repoSlug: string }>
127
}
138

14-
// Main page component
159
export default async function Page({
1610
params,
1711
}: PageProps): Promise<JSX.Element> {
1812
const { ownerSlug, repoSlug } = await params
1913

20-
const fetchRepoService = new FetchRepoService()
21-
const repoDetails = await fetchRepoService.getFullRepositoryTree(
22-
ownerSlug,
23-
repoSlug
24-
)
2514

26-
if (!repoDetails) {
27-
notFound()
28-
}
2915

3016
return (
3117
<div className="flex gap-6 p-6">
3218
<Suspense fallback={<Loading />}>
33-
<div className="flex-1">
34-
<MarkdownContent content={formatToMarkdown(repoDetails)} />
35-
</div>
36-
<div className="w-[300px]">
37-
<RepoCard repoInfo={repoDetails.repository} />
38-
</div>
39-
</Suspense>
19+
<RepositorySummarizationContent
20+
owner={ownerSlug}
21+
repo={repoSlug}
22+
/>
23+
</ Suspense>
4024
</div>
4125
)
4226
}

0 commit comments

Comments
 (0)