Skip to content
refs
31 lines · 1.3 KBRaw
1import { LineBadge } from "@refs/design-system";
2import type { Route } from "./+types/repo-map";
3import { CodeMapPanel } from "../components/code-map/map-states";
4import { found, refs, fullName } from "../lib/session";
5
6export const meta: Route.MetaFunction = ({ params }) => [{ title: `Map · ${fullName(params)} · refs` }];
7
8export async function loader({ params, context, request }: Route.LoaderArgs) {
9 const repo = await found(refs(context).repo(fullName(params)));
10 const asked = new URL(request.url).searchParams.get("ref") ?? undefined;
11 const { ref, map } = await found(repo.codeMap(asked));
12 return { repo: repo.summary.name, ref, map };
13}
14
15export default function RepoMap({ loaderData }: Route.ComponentProps) {
16 const { repo, ref, map } = loaderData;
17 return (
18 <>
19 <div className="mb-2 flex flex-wrap items-center gap-2 text-compact text-muted">
20 <LineBadge name={ref} main />
21 <code className="font-mono text-xs text-faint">{map.commit.slice(0, 7)}</code>
22 {map.kind === "ready" && (
23 <span className="caption text-faint tabular-nums">
24 {map.files} {map.files === 1 ? "file" : "files"} · {map.symbols} {map.symbols === 1 ? "symbol" : "symbols"}
25 </span>
26 )}
27 </div>
28 <CodeMapPanel repo={repo} summary={map} codeHref={`/${repo}`} />
29 </>
30 );
31}