# Prompt para construir um site SEO estático com Astro

> Prompt copiável para scaffolding de um site estático Astro totalmente otimizado com coleções de conteúdo, sitemap, og-images e TypeScript.

**Type:** Prompt  
**Tools:** Cursor, Claude Code, Codex, Windsurf  
**Stack:** Astro, TypeScript, Tailwind  
**Difficulty:** medium  
**Updated:** 2026-06-08

---

Dê isso ao seu agente para criar um site estático Astro pronto para produção com
coleções de conteúdo, Tailwind v4, meta SEO, sitemap e imagens OG por página —
sem que ele invente integrações incompatíveis ou pule tags canônicas.

## Prompt Principal

```txt title="Main Prompt"
You are scaffolding a new Astro static site. Use Astro 5, TypeScript strict mode,
and Tailwind CSS v4 (via @tailwindcss/vite — NOT the legacy @astrojs/tailwind integration).

Requirements:
- Initialize with `bun create astro@latest` defaults, then layer in:
  - A `src/content/blog/` collection with a Zod schema (title, description, pubDate, tags).
  - A shared `<BaseLayout>` with `<head>` containing: canonical URL, og:title, og:description,
    og:image (per-page), twitter:card, and the Astro `<ViewTransitions />` component.
  - `@astrojs/sitemap` integration configured with `customPages` for any dynamic routes.
  - A `public/robots.txt` that disallows `/api/` and allows everything else.
  - A `/blog/[slug].astro` dynamic route that renders MDX blog posts.
  - A `/tags/[tag].astro` route that filters posts by tag.
  - Tailwind applied globally via `src/styles/global.css` imported in BaseLayout.
- All components must be `.astro` — no React unless explicitly asked.
- Export a typed `getStaticPaths` for every dynamic route.
- Do NOT install `@astrojs/react`, `next`, or any SSR adapter — this is a static build.

Stop after listing all files you plan to create or modify. Wait for my approval before writing any code.
```

## Notas de Implementação

- As coleções de conteúdo do Astro 5 usam `defineCollection` em `src/content.config.ts`, não o caminho antigo
  `src/content/config.ts` — confirme que o agente usa a localização correta.
- O Tailwind v4 vem como um plugin Vite; o padrão antigo `integrations: [tailwind()]` no `astro.config.ts`
  está obsoleto e causará um erro de execução.
- `getStaticPaths` deve retornar objetos `{ params, props }`; o agente às vezes retorna strings simples.

## Mudanças Esperadas nos Arquivos

```txt
astro.config.ts                          (new)
src/content.config.ts                    (new)
src/layouts/BaseLayout.astro             (new)
src/pages/index.astro                    (new)
src/pages/blog/[slug].astro              (new)
src/pages/tags/[tag].astro              (new)
src/styles/global.css                    (new)
public/robots.txt                        (new)
package.json                             (edited)
tsconfig.json                            (edited)
```

## Critérios de Aceitação

- `bun run build` encerra com código 0 e sem erros de tipo.
- Cada página de postagem do blog inclui uma URL canônica única e `og:image` no HTML renderizado.
- `/sitemap-index.xml` é gerado e contém todas as URLs dos posts do blog.
- `/robots.txt` existe e desabilita `/api/`.

## Comandos de Teste

```bash
bun run build
bun run preview
curl -s http://localhost:4321/sitemap-index.xml | grep '<loc>'
curl -s http://localhost:4321/robots.txt
bun run typecheck
```

## Erros Comuns da IA

- Instalar o pacote obsoleto `@astrojs/tailwind` em vez de `@tailwindcss/vite`.
- Colocar `content.config.ts` em `src/content/config.ts` (caminho antigo do Astro 4).
- Esquecer de chamar `getCollection('blog')` dentro de `getStaticPaths` — retornando um array vazio.
- Adicionar `output: 'server'` ao `astro.config.ts`, o que quebra a exportação estática.

## Prompt de Correção

```txt title="Fix Prompt"
The build failed. Check for these issues in order:
1. Tailwind: remove `@astrojs/tailwind` from integrations and add `@tailwindcss/vite` to the
   `vite.plugins` array in astro.config.ts.
2. Content config: the file must be at `src/content.config.ts` (not `src/content/config.ts`).
3. `getStaticPaths`: each entry must be `{ params: { slug }, props: { post } }`.
Fix only the broken items. Show me the corrected diff.
```