---
name: evoke-page-manager
description: >
  Scaffolds a new page in this Veeva Astro CLM project. Use this skill whenever the user asks to
  create a new page, add a page, scaffold a slide, generate a new route, or set up a new CLM slide —
  even if they don't say "page manager" explicitly. If the user is working in this project and wants
  a new page, this skill should always trigger.
---

# Page Manager

## Step 1 — Ask for the page path

Ask: "What should the page path be? (relative to `src/contents/`, e.g. `home` or `module-1/slide-2`)"

## Step 2 — Ask for the layout

Read `src/layouts/` to discover available layouts (each subdirectory containing a `.astro` file is a layout). Present them as a numbered list, for example:

```
Which layout would you like to use?
  1. GlobalLayout
  2. LeftNavLayout
  3. TopNavLayout
```

The user can respond with just a number. Resolve it to the layout name (e.g. `TopNavLayout`) before proceeding.

## Step 3 — Check for veeva-config.ts

Check if `veeva-config.ts` exists in the project root. If it does, ask the user: "Would you like to add a slide entry for this page in `veeva-config.ts`?"

## Step 4 — Create files

Given the page path (e.g. `This/One`):
- `contentName` = last segment of the path, preserving its original case (e.g. `One`)
- `pageName` = full path lowercased with `/` replaced by `-` (e.g. `this-one`)

Check that neither `src/pages/<pageName>.astro` nor `src/contents/<path>/` already exist — if either does, stop and tell the user.

**Write `src/pages/<pageName>.astro`:**
```astro
---
import Page from '@/contents/<path>/<contentName>.astro';
---
<Page />
```

**Create `src/contents/<path>/` and write `<contentName>.astro`:**
```astro
---
import <layoutName> from '@/layouts/<layoutName>/<layoutName>.astro';

import './<contentName>.scss';
---
<<layoutName>>
  <!-- Insert page content here -->
  
  <script>
    import './<contentName>';
  </script>
</<layoutName>>
```

**Write `src/contents/<path>/<contentName>.scss`:** empty file

**Write `src/contents/<path>/<contentName>.ts`:** empty file

## Step 5 — Add slide to veeva-config.ts

If the user said yes in Step 3, add a new slide entry to `presentation.slides` following the pattern in `../veeva-config-manager/manage.md` (Step 3 — Resolve missing slides).

## Step 6 — Update Pages array in src/data/pages.tsx

For each page created, build its URL as `/<pageName>/` (must start and end with `/`). Collect these into a `string[]`.

Ask the user: "Would you like me to automatically append these URLs to the `Pages` array in `src/data/pages.tsx`?"

- **If yes:** Edit `src/data/pages.tsx` and append an entry to the `Pages` array for each URL, following the existing `Page` interface shape (`{ title: JSX.Element, href: string }`). The title is the `pageName` split on `-` with each segment capitalized and joined by spaces, e.g. for `pageName` `module-1-slide-2`:
  ```tsx
  { title: <>Module 1 Slide 2</>, href: '/module-1-slide-2/' }
  ```
- **If no:** Log the URLs to the console so the user can copy them manually.

## Step 7 — Report

Tell the user which files were created and whether `src/data/pages.tsx` was updated (or print the URL list if it wasn't).
