---
import { getCollection } from 'astro:content';
import { ArrowRight, ArrowUpRight, Bot, FileCode, FlaskConical, Workflow } from '@lucide/astro';
import ExampleIcon from '../../components/ExampleIcon.astro';
import Pager from '../../components/Pager.astro';
import Base from '../../layouts/Base.astro';
import { exampleNumber, sortExamples } from '../../lib/examples';
import { searchSection } from '../../lib/search';
import '../../styles/examples.css';
const examples = sortExamples(await getCollection('examples'));
const total = exampleNumber(examples.length - 1);
// The closing card takes whatever the last row leaves open (a full row when
// the cards divide evenly), at both the 3- and 2-column layouts.
const open = (cols: number) => cols - (examples.length % cols);
const closingSpans = `--span-3: ${open(3)}; --span-2: ${open(2)}`;
// What every example page contains, in page order.
const anatomy = [
{ icon: FileCode, label: 'A complete devsandboxes.toml' },
{ icon: FlaskConical, label: 'Commands to try it' },
{ icon: Workflow, label: 'How it works' },
{ icon: Bot, label: 'A prompt for your agent' },
];
---
<Base
title="Examples"
description="Complete, validated devsandboxes.toml recipes for devsandboxes: parallel agents, shared and isolated services, caches, ssh-agent forwarding and more."
>
<main id="main-content" class="examples-page" tabindex="-1" data-pagefind-body data-pagefind-meta={`section:${searchSection('/examples')}`}>
<header class="examples-hero">
<div class="examples-hero-grid" aria-hidden="true"></div>
<div class="examples-hero-inner">
<div class="examples-hero-copy">
<p class="examples-kicker"><span>// EXAMPLES · {total} RECIPES</span></p>
<h1 data-pagefind-meta="title:Examples">Start from a recipe<span class="title-period" aria-hidden="true">.</span></h1>
<p class="examples-lead">
Each example is one use case, end to end: the whole config, the commands to try it, what happens underneath,
and a prompt that has your coding agent set it up in your own config.
</p>
</div>
<ol class="examples-anatomy" aria-label="Every example contains">
{
anatomy.map((a, i) => (
<li>
<span class="examples-anatomy-number">{exampleNumber(i)}</span>
<a.icon size={16} aria-hidden="true" />
{a.label}
</li>
))
}
</ol>
</div>
</header>
{/* The cards repeat every example's title and description; those pages are indexed themselves. */}
<section class="examples-list" aria-label="All examples" data-pagefind-ignore>
<div class="feature-grid examples-grid">
{
examples.map((e, i) => (
<a class="feature-card example-index-card" href={`/examples/${e.id}`}>
<div class="feature-top">
<span class="feature-icon">
<ExampleIcon name={e.data.icon} size={21} />
</span>
<span class="feature-number">
{exampleNumber(i)} / {total}
</span>
</div>
<h2>{e.data.title}</h2>
<p>{e.data.description}</p>
<ul class="example-card-tags" aria-label="Tags">
{e.data.tags.map((t) => (
<li>{t}</li>
))}
</ul>
<span class="feature-link">
Open the recipe
<ArrowUpRight size={16} aria-hidden="true" />
</span>
</a>
))
}
{/* Closes the grid: spans the columns the last row leaves open. */}
<aside class="examples-closing" aria-labelledby="examples-closing-title" style={closingSpans}>
<p class="examples-closing-kicker">// NEXT STEPS</p>
<h2 id="examples-closing-title">
New to devsandboxes<span class="title-period">?</span>
</h2>
<p>
The quick start gets a first sandbox running; the configuration reference has every field these recipes use.
</p>
<div class="examples-closing-actions">
<a class="button-primary" href="/docs/quick-start">
Quick start <ArrowRight size={16} aria-hidden="true" />
</a>
<a class="button-secondary" href="/docs/config">
Configuration reference
</a>
</div>
</aside>
</div>
<Pager />
</section>
</main>
</Base>