# Content

What each route returns, and how the pieces fit a page. Field-level detail is in the [API reference](https://developers.velora.build/reference.md).

## The site

`/site` is everything that renders around the content, in one read per page:

- `name`, `url` (the site's public origin, when Velora knows it; use it for canonical URLs, the sitemap and the feed) and `language` (a language tag such as `en-GB`).
- `settings`: the title, description, logo, default share image, social links, SEO defaults and `time_zone`.
- `navigation`: `primary` and `footer`, each a list of `{label, url}`. Render them in order. `url` is a path on the site or a full URL.
- `categories` (sections, with their `parent`), `entity_types`, and `article_details` (below).

## The front page

`/home` returns the front page's `sections` in the order the editor chose in Velora. Render each in turn; change the order in Velora, not in code.

- `kind: "articles"`: a run of `articles` (cards).
- `kind: "entity_type"`: a run of `entities` of one type.

Each section can have a `title`, a `path` to link "more" to, and a `key`: the name the site gave the section, for your front end to place or style it by.

## Listings

`/articles` lists live articles, newest first. Filter it with:

| Parameter | Filters by |
| --- | --- |
| `category` | Section slugs. Several, comma separated, match any. |
| `tag` | Tag slugs, comma separated. |
| `type` | Article types, comma separated: `type=news,race`. |
| `author` | A writer's slug. |
| `entity_type` + `entity` | Articles about one entity: its type's slug and its own. |
| `detail` + `value` | An [article detail](#details): `detail=Sponsored&value=true`. A detail that links to an entity takes the entity's slug. |
| `match` | `all` (the default): an article must match every filter. `any`: it may match any of `category`, `tag` and `type`. |

Section, writer and entity pages have their own listing routes, which return the thing and its articles together: `/categories/{slug}`, `/authors/{slug}` and `/entities/{type_slug}/{slug}`.

Article cards (`ArticleCard`) carry what a list needs: `title`, `path`, `excerpt`, `eyebrow`, `cover`, dates, `reading_minutes`, `category`, `authors`, `tags` and `details`.

## Paging

Listings page two ways.

**By number**, for pages a reader visits: `page` (1 to 500) and `limit` (1 to 50, 12 by default; entity type indexes take up to 100, 48 by default). The answer has `page`, `pages` and `total`. Give each page a path ([Routing](https://developers.velora.build/routing.md#later-pages-of-a-listing)).

**By cursor**, for "load more" and for walking the whole archive. Every `/articles` answer has `next_cursor`; pass it back as `cursor` for the articles after the last one you got. It is `null` on the last page. An ISO time works as a cursor too: `cursor=2019-06-01T00:00:00Z` starts with the articles published before then. Cursors go past page 500. A read with a cursor is never cached anywhere, so do not cache it yourself.

## An article

`/articles/{slug}` returns an `ArticleDetail`: everything on the card, plus

- `body` (Portable Text), `html` (the same body as HTML) and `word_count`. Add `?format=markdown` for `markdown` too. See [Article bodies](https://developers.velora.build/bodies.md).
- `authors` in full, with `bio`, `social` links (a map of network to URL) and article counts.
- `seo`: `title`, `description`, `image_url` and `canonical_path`. Use them for the page's metadata and canonical link.
- `entities`: who and what the article is about, each with a `name`, `path`, `type_slug`, `type_name` and `image`. Only entities that have a page are listed, so every one can be a link.
- `corrections`: dated notes (`at`, `note`) to show readers.
- `related`: up to four cards from the same section.

### Details

Details are a site's own structured fields: a race's date, whether a story is sponsored, the team a rider rides for. Articles and entities both have them.

- The shape is declared once: `/site` has `article_details`, and each entity type in `entity_types` has `details`. Each is a `DetailView`: its `key`, its `kind` (`text`, `number`, `date`, `boolean`, `url`, `choice` or `link`), `options` for a choice, and for a link, the entity type it `links_to` and whether it holds `many`.
- The values are on each article (`details`) and entity (`fields`), keyed by `key`, in the declared order. A detail with no value is left out.
- A `link` value is a `LinkedEntity` (`id`, `slug`, `name`, `type_slug`, `path`), or a list of them when the detail holds many. `path` is `null` when that entity has no page: show the name without a link.

## Entities

- `/entities/{type_slug}` is a type's index (`/riders`): its entities that have a page, by number. With `via` and `to`, it lists instead every entity whose `via` detail links to the entity `to` names, with a page or not: `via=Team&to=ineos` lists a team's riders.
- `/entities/{type_slug}/{slug}` is one entity: `name`, `summary`, `image`, `fields` (its [details](#details)), `bio` (Portable Text) and `bio_html`, a page of its articles in `articles_page` (pass `page` and `limit`), and `linked_from`: the entities linking to it, grouped by type and detail (a team's riders, by Team).
- `seo.index` says whether search engines should index the page. Add `noindex` when it is `false`.

## Writers, sections, pages and tags

- `/authors` lists writers; `/authors/{slug}` is one writer with a page of their articles.
- `/categories` lists sections in the site's order, each with its `parent` when it has one. `/categories/{slug}` is a section with a page of its articles.
- `/pages/{slug}` is a static page (`/about`): `title`, `body`, `html`, `seo_title`, `seo_description`, `updated_at`.
- `/tags` lists the tags on live articles, most used first, with counts. Tags filter listings but have no page of their own.

## Search

`/search?q=...` finds live articles: words, `"quoted phrases"` and `-excluded` words, best match first, paged by `page` and `limit`. `q` is 2 to 200 characters. Search is never cached; render it per request on a route kept for your front end (Velora keeps `/search` by default).
