g1t/apps/web/app/routes/repo/tree.tsx
| 1 | import type { Route } from "./+types/tree"; |
| 2 | import { page } from "../../lib/meta"; |
| 3 | import { TreeView } from "../../components/repo-view"; |
| 4 | import { repos } from "../../lib/services.server"; |
| 5 | import { getViewer, unwrap } from "../../lib/session.server"; |
| 6 | |
| 7 | export function meta({ params, ...args }: Route.MetaArgs) { |
| 8 | const path = params["*"] ? `${params["*"]} · ` : ""; |
| 9 | return page(args, { title: `${path}${params.owner}/${params.repo} · g1t` }); |
| 10 | } |
| 11 | |
| 12 | export async function loader({ params, context }: Route.LoaderArgs) { |
| 13 | const path = { namespace: params.owner, name: params.repo }; |
| 14 | return unwrap( |
| 15 | await repos.tree(path, getViewer(context), params.ref, params["*"] ?? ""), |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | export default function Tree({ loaderData }: Route.ComponentProps) { |
| 20 | return <TreeView tree={loaderData} />; |
| 21 | } |