Commit

Topics sit in About on the files pages, under the description

syntaqxcommitted Parent8b7fa02Browse files
3 files+27−190/3 viewed
+2−0
99 import { AgentSetup } from "./agent-setup";
1010 import { CloneBox } from "./clone-box";
1111 import { Markdown } from "./markdown";
12+import { Topics } from "./topics";
1213 import { Avatar, CopyLine, TimeAgo, notACredential } from "./ui";
1314 import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuTrigger } from "./ui/dropdown-menu";
1415 import { Popover, PopoverContent, PopoverTrigger } from "./ui/popover";
268269 <aside>
269270 <h2 className="text-base font-semibold">About</h2>
270271 <p className="mt-2.5 text-sm text-fg-soft">{repo.description ?? "No description."}</p>
272+ <Topics topics={repo.topics} className="mt-3" />
271273 <ul className="mt-4 space-y-2.5 text-sm text-muted">
272274 {readme && (
273275 <li>
+19−0
1+import { Link } from "react-router";
2+
3+/** A repository's topics, each a link to Explore filtered by it. */
4+export function Topics({ topics, className = "mt-2" }: { topics: string[] | undefined; className?: string }) {
5+ if (!topics?.length) return null;
6+ return (
7+ <div className={`${className} flex flex-wrap gap-1.5`}>
8+ {topics.map((topic) => (
9+ <Link
10+ key={topic}
11+ to={`/explore?topic=${encodeURIComponent(topic)}`}
12+ className="rounded-full bg-accent/10 px-2 py-px text-xs text-accent ring-1 ring-accent/30 transition-colors hover:bg-accent/20"
13+ >
14+ {topic}
15+ </Link>
16+ ))}
17+ </div>
18+ );
19+}
+6−19
44 import type { Project } from "@g1t/contracts";
55
66 import type { Route } from "./+types/layout";
7+import { Topics } from "../../components/topics";
78 import { page } from "../../lib/meta";
89 import { type Tab as PageTab, tabsFor } from "../../lib/project-nav";
910 import { Pill } from "../../components/ui";
7475 }
7576
7677 /** A repository's topics, each a way into Explore. */
77−function Topics({ topics }: { topics: string[] | undefined }) {
78− if (!topics?.length) return null;
79− return (
80− <div className="mt-2 flex flex-wrap gap-1.5">
81− {topics.map((topic) => (
82− <Link
83− key={topic}
84− to={`/explore?topic=${encodeURIComponent(topic)}`}
85− className="rounded-full bg-accent/10 px-2 py-px text-xs text-accent ring-1 ring-accent/30 transition-colors hover:bg-accent/20"
86− >
87− {topic}
88− </Link>
89− ))}
90− </div>
91− );
92−}
93−
9478 function Header({ project, isPrivate, archived, namespace, name, description, large }: {
9579 project: Project | null;
9680 isPrivate: boolean;
171155 const description = (project && !project.descriptionInherited ? project.description : null) ?? repo.description;
172156 const { pathname } = useLocation();
173157 const tabs = tabsFor(pathname.slice(base.length + 1), member, access.can);
158+ // The files' own About says what it is and its topics, as the one place.
159+ const filesPage = /^(code|tree)(\/|$)/.test(pathname.slice(base.length + 1));
174160 // Everyone, signed in or not, finds the project's pages in the sidebar;
175161 // the page shows its name, and the views of the page it is on as tabs.
176162 return (
184170 namespace={repo.namespace}
185171 name={repo.name}
186172 // The files' own About says it there, as the one place.
187− description={/^(code|tree)(\/|$)/.test(pathname.slice(base.length + 1)) ? null : description}
173+ description={filesPage ? null : description}
188174 />
189− <Topics topics={repo.topics} />
175+ {/* On the files' pages, About shows them. */}
176+ {!filesPage && <Topics topics={repo.topics} />}
190177 {tabs && (
191178 <div className="mt-3">
192179 <PageTabs base={base} tabs={tabs} />