Skip to content

refactor: change repo to /~/[repo] dynamic route #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/app/(app)/[repo]/page.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/(app)/new/_components/repo-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export default function RepoList() {
<span className="text-muted-foreground text-sm">
{datetime(repo.updated_at).fromNow()}
</span>
<Button asChild className="ml-auto">
<Link href={`/@${repo.name}`}>Import</Link>
<Button className="ml-auto" asChild>
<Link href={`/~/${repo.name}`}>Import</Link>
</Button>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { toast } from 'sonner';

interface Props {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
setOpen: (val: boolean) => void;
repo: string;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Skeleton } from '@/components/ui/skeleton';

export default function ContentsSkeleton() {
export default function RepoContentsSkeleton() {
return Array.from({ length: 1 }).map((_, idx) => (
<div key={idx} className="grid grid-cols-5 gap-2 p-3">
<Skeleton className="col-span-2 h-5 w-20" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Folder, Plus, Search } from 'lucide-react';
import { useCallback, useEffect } from 'react';
import { toast } from 'sonner';
import ContentItem from './content-item';
import ContentsSkeleton from './contents-skeleton';
import RepoContentsSkeleton from './repo-contents-skeleton';

interface Props {
repo: string;
setIsConfigDialogOpen: React.Dispatch<React.SetStateAction<boolean>>;
setIsConfigDialogOpen: (val: boolean) => void;
}

export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
Expand Down Expand Up @@ -65,7 +65,7 @@ export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
return (
<div className="col-span-2 flex flex-col gap-2">
<div className="flex items-center gap-4">
<div className="flex items-center gap-2">
<div className="flex items-end gap-2">
<Avatar className="size-5">
<AvatarImage src={session?.user?.image ?? undefined} />
<AvatarFallback>{session?.user?.name?.[0]}</AvatarFallback>
Expand All @@ -75,7 +75,7 @@ export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
className="text-sm font-bold hover:underline"
onClick={() => navigateBackTo('<root>')}
>
@{repo}
{repo}
</button>
{breadcrumbs.length > 0 && <span className="text-muted-foreground/50">/</span>}
{breadcrumbs.map((crumb, idx) => (
Expand Down Expand Up @@ -118,7 +118,7 @@ export default function RepoContents({ repo, setIsConfigDialogOpen }: Props) {
</button>
)}
{isLoading || status === 'loading' || !contents ? (
<ContentsSkeleton />
<RepoContentsSkeleton />
) : (
contents.map((content) => (
<ContentItem
Expand Down
17 changes: 17 additions & 0 deletions src/app/(app)/~/[repo]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Metadata } from 'next';
import ClientPage from './client-page';

interface Props {
params: Promise<{ repo: string }>;
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { repo } = await params;
return { title: `${repo}: GitLoom` };
}

export default async function Page({ params }: Props) {
const { repo } = await params;
// render client-side page
return <ClientPage repo={repo} />;
}