flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/web/app/routes/explore.tsx

55 lines2,169 bytesCodeBlame
1import { Search } from "lucide-react";
2import { Form } from "react-router";
3
4import type { Route } from "./+types/explore";
5import { page } from "../lib/meta";
6import { RepoList } from "../components/repo-list";
7import { notACredential } from "../components/ui";
8import { repos } from "../lib/services.server";
9import { getViewer } from "../lib/session.server";
10
11export function meta({ loaderData, ...args }: Route.MetaArgs) {
12 return page(args, {
13 title: loaderData?.query ? `${loaderData.query} · Search · g1t` : "Explore · g1t",
14 description: loaderData?.query
15 ? `Public repositories on g1t matching "${loaderData.query}".`
16 : "Public repositories on g1t, and the agents at work on them.",
17 });
18}
19
20/** Serves both /explore and /search?q=. */
21export async function loader({ request, context }: Route.LoaderArgs) {
22 const query = new URL(request.url).searchParams.get("q")?.trim() ?? "";
23 return { query, repos: await repos.list(getViewer(context), { query }) };
24}
25
26export default function Explore({ loaderData }: Route.ComponentProps) {
27 const { query, repos } = loaderData;
28 return (
29 <main className="mx-auto max-w-4xl px-4 py-10">
30 <h1 className="text-2xl font-semibold tracking-tight">
31 {query ? "Search" : "Explore"}
32 </h1>
33 <p className="mt-1 text-muted">
34 {query
35 ? `${repos.length} ${repos.length === 1 ? "repository matches" : "repositories match"} "${query}".`
36 : "Public repositories on g1t."}
37 </p>
38 <Form action="/search" role="search" className="relative mt-6">
39 <Search
40 size={16}
41 className="pointer-events-none absolute top-1/2 left-3.5 -translate-y-1/2 text-faint"
42 />
43 <input
44 name="q"
45 {...notACredential()}
46 defaultValue={query}
47 placeholder="Search by name or description"
48 aria-label="Search repositories"
49 className="w-full rounded-lg border border-line bg-surface py-2.5 pr-4 pl-10 outline-none transition-colors placeholder:text-faint hover:border-line-strong focus:border-accent-dim"
50 />
51 </Form>
52 <RepoList repos={repos} />
53 </main>
54 );
55}