# Maintaining This Book

The master copy of this book is in the website repository at `docs/bookstack/`, next to the code it describes. It's written as Markdown, one file per page, and packaged into a BookStack import file.

```
docs/bookstack/
├── book.json            # book/chapter names, descriptions, tags, page order
├── build-book.mjs       # packs everything into a BookStack ZIP
└── pages/
    ├── 01-overview/*.md
    ├── 02-admin/*.md
    ├── 03-developer/*.md
    └── 04-reference/*.md
```

## When to update it

- **A developer changes behaviour** that editors or admins see: update the *Administrator Guide* in the same pull request.
- **A new CMS field, env var, integration, or route**: update the matching *Developer Guide* and *Reference* pages.
- **A known issue is fixed**: update its status in *Known Issues and Open Items*.
- **Staff find an instruction unclear**: fix it here.

## Two ways to edit

**Option A: edit in BookStack.** Quick, but the repository copy goes stale. If you edit in BookStack, tell the developer so they can copy the change back into `docs/bookstack/pages/`. Otherwise the next re-import will overwrite it.

**Option B: edit in the repository (recommended for structural changes).**

1. Edit or add Markdown files under `docs/bookstack/pages/`. Don't repeat the page title as a heading; BookStack shows it. Start sections at `##`.
2. Register new pages in `book.json`. Array order sets the page order.
3. Build the import file:

   ```bash
   node docs/bookstack/build-book.mjs
   # → docs/bookstack/fort-adams-website-book.zip
   ```

4. In BookStack, go to **Books → Import** (or **Settings → Import**, depending on version), upload the ZIP, review, and import. You need BookStack **v24.12 or newer** and the *Import content* permission.

## Re-importing

A ZIP import always creates a **new** book; it doesn't merge into the existing one. To replace the book:

1. Import the new ZIP. It appears as a second book.
2. Check it, then move over any edits made only in the old copy.
3. Delete the old book, or move it to an archive shelf. Note that links and bookmarks to old pages will change.

For small changes, it's usually easier to edit the one page in BookStack and mirror the change in the repository.

## Formatting notes

- Callout boxes use BookStack's HTML classes inside Markdown: `<p class="callout info|success|warning|danger">…</p>`. Markdown formatting doesn't work inside these; use `<strong>` and `<em>`.
- Tables, fenced code blocks, and task lists (`- [ ]`) are supported.
- Refer to other pages by name in *italics*, for example *Managing Special Events*, rather than by URL, so references survive re-imports.