## Suturly Web App

This Next.js app reads published content from Sanity and renders:

- Resource list on `/`
- Resource detail on `/resources/[slug]`
- Published chapters only (`status == "published"`)

## Setup

Copy and configure environment variables:

```bash
cp .env.local.example .env.local
```

Set these values in `.env.local`:

- `NEXT_PUBLIC_SANITY_PROJECT_ID`
- `NEXT_PUBLIC_SANITY_DATASET` (usually `production`)
- `NEXT_PUBLIC_SANITY_API_VERSION` (for example `2025-01-01`)

## Development

```bash
npm run dev
```

Open [http://localhost:3000](http://localhost:3000).

## Notes

- If a resource has no chapter with `published` status, the detail page shows a fallback message.
- Preview mode is available via Next.js draft mode.

## Preview mode (draft + published)

1. Set these in `.env.local`:
   - `SANITY_API_READ_TOKEN`
   - `SANITY_PREVIEW_SECRET`
2. Start app:
   - `npm run dev`
3. Enable preview in browser:
   - `http://localhost:3000/api/preview?secret=YOUR_SECRET&slug=/`
4. Exit preview:
   - `http://localhost:3000/api/preview/exit`

When preview is enabled, resource pages show all chapters and chapter status badges.

## Build

```bash
npm run build
```
