| 1 | import { env } from "cloudflare:workers"; |
| 2 | |
| 3 | import type { Route } from "./+types/blob"; |
| 4 | import { BlobView } from "../../components/repo-view"; |
| 5 | import { getViewer, unwrap } from "../../lib/session.server"; |
| 6 | |
| 7 | export function meta({ params }: Route.MetaArgs) { |
| 8 | return [{ title: `${params["*"]} · ${params.owner}/${params.repo} · g1t` }]; |
| 9 | } |
| 10 | |
| 11 | export async function loader({ params, context }: Route.LoaderArgs) { |
| 12 | const path = { namespace: params.owner, name: params.repo }; |
| 13 | return unwrap( |
| 14 | await env.REPOS.blob(path, getViewer(context), params.ref, params["*"] ?? ""), |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | export default function Blob({ loaderData }: Route.ComponentProps) { |
| 19 | return <BlobView blob={loaderData} />; |
| 20 | } |