g1t/apps/docs/src/components/AgentSetup.astro
| 1 | --- |
| 2 | // How to connect a coding agent to g1t: a tab per agent. Every block on |
| 3 | // the page switches together, and Starlight remembers the choice |
| 4 | // (`syncKey`). The snippets live in `src/data/agents.ts`. |
| 5 | import { Code, TabItem, Tabs } from '@astrojs/starlight/components'; |
| 6 | |
| 7 | import { AGENTS, AGENTS_WITH_TOKEN } from '../data/agents'; |
| 8 | |
| 9 | interface Props { |
| 10 | /** `token` shows each agent with a bearer token instead of signing in through the browser. */ |
| 11 | variant?: 'browser' | 'token'; |
| 12 | } |
| 13 | |
| 14 | const { variant = 'browser' } = Astro.props; |
| 15 | const agents = variant === 'token' ? AGENTS_WITH_TOKEN : AGENTS; |
| 16 | const parts = (text: string) => text.split('`').map((part, index) => ({ part, code: index % 2 === 1 })); |
| 17 | --- |
| 18 | |
| 19 | <Tabs syncKey="agent"> |
| 20 | { |
| 21 | agents.map((agent) => ( |
| 22 | <TabItem label={agent.label}> |
| 23 | <Code code={agent.code} lang={agent.lang} title={agent.file ?? undefined} frame={agent.file ? 'code' : 'none'} /> |
| 24 | {agent.then && ( |
| 25 | <p> |
| 26 | {parts(agent.then).map(({ part, code }) => (code ? <code>{part}</code> : part))} |
| 27 | </p> |
| 28 | )} |
| 29 | </TabItem> |
| 30 | )) |
| 31 | } |
| 32 | </Tabs> |