# Calendar

<StatusBadge status="available" /> `format: calendar` turns a story into a **calendar**:
one **event** per scene, written in the **wall time** of its zone. The same file is shown as a
month, a week, an agenda and a year, filtered by tag and read in the reader's own zone on request;
each event has its own page, and the calendar is exported to a feed that any calendar app
subscribes to (`.ics`) and to a PDF.

The examples are `calendar-meetups` (JSON, two languages) and `calendar-course` (Markdown, two
languages, recurrences across the changes of time); calendar.recit.dev shows both, and the releases
of Récit. Times, zones and the changes of time have their own page:
[Time zones and changes of time](/formats/calendar/time-zones).

## A minimal calendar

```md title="meetups.md"
---
title: Lorem Meetups
format: calendar
lang: en
timezone: Europe/Paris
view: month
---

--- id=kickoff start=2026-11-05T18:30 end=2026-11-05T20:30 location="Lorem Hall, Ipsum" tags=meetup

## Kickoff meetup

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

--- id=office-hours start=2026-11-03T10:00 duration=1h rrule="FREQ=WEEKLY;BYDAY=TU;COUNT=8" timezone=America/New_York url=https://example.com/live

## Office hours

--- id=retreat date=2026-12-10 end=2026-12-12

## Ipsum retreat
```

```bash
npx recit dev meetups.md
```

| Attribute            | What it is                                                                                                                                                           |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `start`              | a wall time, `YYYY-MM-DDTHH:MM`, in the event's `timezone`, else the calendar's                                                                                      |
| `end` or `duration`  | one or the other, never both. `duration`: `1h`, `90m`, `1h30m` or ISO 8601 (`PT1H30M`)                                                                               |
| `date`               | an all-day event; with `end` (a date), over several days, **`end` included**                                                                                         |
| `timezone`           | an IANA zone (`America/New_York`); not on a `date` event                                                                                                             |
| `rrule`, `exdate`    | an RFC 5545 rule without its `RRULE:` prefix; the dates it skips, comma-separated, written like `start`                                                              |
| `location`           | free text, `@id` of an entry of the `places` directory, or a place in JSON (`{"name": …, "city": …, "geo": [lat, lon]}`)                                             |
| `url`, `tags`        | a link (a video call, tickets), tags the views filter on                                                                                                             |
| `status`             | `confirmed` (default), `tentative`, `cancelled`: a cancelled event stays, struck through, `STATUS:CANCELLED`                                                         |
| `deck`, `film`       | a linked story: "See the deck", "See the film"                                                                                                                       |
| `register`           | the sign-up form: its anchor (`#form-signup` for `:::form{#signup}`), a path or an address; "Register" opens it with `?recit-about=<event id>`, sent as `meta.about` |
| `color`              | a lightness of the site's hue, `soft`, `base` or `strong`, never a free color                                                                                        |
| the heading and body | the first heading is the event's title, the rest its description, in full Markdown                                                                                   |

The attributes fit on the separator line. A long one is written in JSON instead
(`--- {"id": "office-hours", …}`).

## Settings

In the front matter, or for every calendar of a folder in the `calendar:` section of
`recit.config.ts` (the front matter wins).

| Setting          | Default                       | What it does                                                                          |
| ---------------- | ----------------------------- | ------------------------------------------------------------------------------------- |
| `timezone`       | none                          | the zone of the wall times; required once an event has a time                         |
| `view`           | `month`                       | the view shown first: `month`, `week`, `agenda` or `year`                             |
| `firstDay`       | the language's                | `monday`, `sunday` or `saturday`                                                      |
| `window`         | `{ past: P3M, future: P12M }` | the occurrences computed around the build day, `past` and `future` as ISO durations   |
| `maxOccurrences` | `500`                         | the most occurrences computed per event                                               |
| `noOverlap`      | `false`                       | two overlapping occurrences are an error                                              |
| `url`            | none                          | where the calendars are published (`https://…/calendar/`): the host of the UIDs       |
| `places`         | none                          | the `directory` story that resolves `location=@id`, relative to the calendar's folder |
| `pdf`            | A4 portrait, a month          | `recit export --to pdf`: `view` (`month` or `agenda`), `from`, `months`, the page box |

`include:` lists the roadmaps whose milestones join the calendar; it belongs to the story, so it is
written in the front matter only ([Bridges](#bridges)). The `pdf` key takes the
[PDF options](/documentation/configuration/recit-config#pdf-options) of every paginated format
(`page`, `toc`, `header`, `footer`, `colorMode`, `output`…), plus `view`, `from` and `months`.

```ts title="recit.config.ts"
import { defineConfig } from "recit/config";

export default defineConfig({
  i18n: { defaultLocale: "en", locales: ["en", "fr"] },
  calendar: {
    timezone: "Europe/Paris",
    firstDay: "monday",
    window: { past: "P3M", future: "P12M" },
    url: "https://example.com/calendar/",
    places: "./places.md",
    pdf: { view: "agenda", months: 3 },
  },
});
```

## The JSON twin

A calendar is the same story in Markdown and in JSON (`kind: "story"`, checked by
`https://recit.dev/schema/v1/calendar.json`), converted both ways by `recit convert`. In JSON, a
title, a description and a place's name hold one value per language; the times, the rules and the
places do not change from one language to the other.

```json title="meetups.json"
{
  "$schema": "https://recit.dev/schema/v1/calendar.json",
  "kind": "story",
  "version": 1,
  "format": "calendar",
  "meta": {
    "title": { "en": "Lorem Meetups", "fr": "Rencontres Lorem" },
    "lang": "en"
  },
  "settings": { "timezone": "Europe/Paris", "view": "month" },
  "scenes": [
    {
      "id": "kickoff",
      "title": { "en": "Kickoff meetup", "fr": "Rencontre de lancement" },
      "start": "2026-11-05T18:30",
      "end": "2026-11-05T20:30",
      "location": {
        "name": { "en": "Lorem Hall", "fr": "Salle Lorem" },
        "city": "Ipsum",
        "geo": [48.85, 2.35]
      },
      "tags": ["meetup"],
      "body": {
        "en": "Lorem ipsum dolor sit amet.",
        "fr": "Lorem ipsum dolor sit amet."
      }
    }
  ]
}
```

In Markdown, the French variant is a file beside the first, `course.fr.md` beside `course.md`, with
the same ids, times and rules.

Alongside `scenes.id` and `scenes.body` (see
[Scenes › In the JSON twin](/documentation/writing/scenes#in-the-json-twin)) and the schedule,
`scenes.title`, `scenes.tags` and `scenes.location` (`location.name`, `location.city`,
`location.geo`, or a free-text / `@id` string) fields shown above, each event in `scenes` accepts
these keys:

| Key                 | Type / values                                   | Effect                                                                                                                                            |
| ------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `scenes.allDay`     | `boolean`                                       | Implied by `scenes.date`; setting `allDay: true` together with `scenes.start` is an error (`calendar-start`).                                     |
| `scenes.url`        | `string` (URI)                                  | Event link (such as a video call or ticket office), exported as `URL` in `.ics` and used as the online URL in JSON-LD when unplaced.              |
| `scenes.status`     | `"confirmed"` \| `"tentative"` \| `"cancelled"` | Event status (`"confirmed"` when omitted; `"cancelled"` keeps the event struck through and writes `STATUS:CANCELLED` in `.ics`).                  |
| `scenes.deck`       | `string` (non-empty)                            | Link to a related deck ("See the deck" on the event detail and event page).                                                                       |
| `scenes.film`       | `string` (non-empty)                            | Link to a related film ("See the film" on the event detail and event page).                                                                       |
| `scenes.register`   | `string` (non-empty)                            | The sign-up form: its anchor (`#form-signup` for `:::form{#signup}`), a path or an address; « Register » opens it with `?recit-about=<event id>`. |
| `scenes.color`      | `"soft"` \| `"base"` \| `"strong"`              | Lightness variant of the site's hue on the event card (`"base"` when omitted), never an arbitrary CSS color.                                      |
| `scenes.notes`      | `string` or `Record<string, string>`            | Optional author notes in Markdown (`:::notes`; [Scenes](/documentation/writing/scenes#in-the-json-twin)).                                         |
| `scenes.attrs`      | `Record<string, string \| number \| boolean>`   | Optional separator attributes (`--- key=value`) not covered by a typed event field ([Scenes](/documentation/writing/scenes#in-the-json-twin)).    |
| `location.address`  | `string`                                        | Free-text display address on an inline `scenes.location` place, shown as written and never parsed into structured postal fields.                  |
| `location.street`   | `string`                                        | Street address on an inline `scenes.location` place.                                                                                              |
| `location.postcode` | `string`                                        | Postal code on an inline `scenes.location` place.                                                                                                 |
| `location.region`   | `string`                                        | Region, state or administrative area on an inline `scenes.location` place.                                                                        |
| `location.country`  | `string` (`^[A-Z]{2}$`)                         | ISO 3166-1 alpha-2 country code (such as `"FR"`) on an inline `scenes.location` place.                                                            |

## Commands

| Command                                                             | What it does                                                                                            |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| `recit dev meetups.md`                                              | the calendar with live reload                                                                           |
| `recit build meetups.md -o dist`                                    | the four views and a page per event, prerendered in the calendar's zone (`-o, --output`, `./dist`)      |
| `recit validate meetups.md`                                         | the story against its schema and the rules below                                                        |
| `recit convert meetups.md --to json -o meetups.json`                | the JSON twin; `--to md` goes back to Markdown (`--locale fr` picks the language)                       |
| `recit convert agenda.ics --to md`                                  | imports an iCalendar file; what Récit does not read (`ATTENDEE`, `VALARM`, `X-…`) is listed as warnings |
| `recit export meetups.md --to ics -o meetups.ics`                   | the feed: one `VEVENT` per event, `RRULE` and `EXDATE` kept, a `VTIMEZONE` per zone, stable `UID`s      |
| `recit export meetups.md --to pdf -o meetups.pdf --color-mode dark` | a page per month, or the agenda, A4 portrait (`--color-mode light` or `dark`)                           |

`-o, --output` names the file (a folder for `build`); without it the export is written beside the
story, `meetups.ics` or `meetups.pdf`, and listed in `exports.json` (`--no-manifest` leaves the
manifest alone). `--locale fr` exports one language of a bilingual calendar. Every command and its
flags are in [the CLI reference](/documentation/reference/cli).

### The feed

The feed carries `REFRESH-INTERVAL` and `X-WR-CALNAME` for the apps that subscribe to it; the
"Subscribe" button of a page offers `webcal://`, Google Calendar, Outlook and the file itself, with
no third-party script. A site build writes `/calendar/<slug>.ics` (and `/fr/calendar/<slug>.ics`)
and one `/calendar/<slug>/<id>.ics` per event, all listed in `exports.json`. Serve `.ics` files as
`text/calendar; charset=utf-8`.

### The rules

`recit validate` reports each one with its file and line, or its JSON path
(`meetups.json /scenes/3/rrule`).

| Code                          | Severity | When                                                               |
| ----------------------------- | -------- | ------------------------------------------------------------------ |
| `calendar-start`              | error    | neither `start` nor `date`, or both; `end` and `duration` together |
| `calendar-date-order`         | error    | `end` before `start` (or before `date`)                            |
| `calendar-unknown-timezone`   | error    | a zone `Intl` does not know                                        |
| `calendar-missing-timezone`   | error    | an event with a time in a calendar without `timezone`              |
| `calendar-invalid-rrule`      | error    | a rule that does not parse, `UNTIL` and `COUNT` together           |
| `calendar-overlap`            | error    | two occurrences overlap, only with `noOverlap: true`               |
| `calendar-nonexistent-time`   | warning  | a wall time that does not exist (spring forward)                   |
| `calendar-ambiguous-time`     | warning  | a wall time that exists twice (fall back)                          |
| `calendar-exdate-mismatch`    | warning  | an `exdate` that matches no occurrence                             |
| `calendar-occurrences-capped` | warning  | the expansion stopped at `maxOccurrences`                          |

## Bridges

| From → to           | How                                      |
| ------------------- | ---------------------------------------- |
| roadmap → calendar  | `include:` in the front matter           |
| calendar → webstory | `recit convert meetups.md --to webstory` |
| calendar → atlas    | `recit convert meetups.md --to atlas`    |

All three are owned by their target, the exception written on the [Bridges](/formats/bridges) page.

### From a roadmap: `include:`

`include:` lists roadmaps (paths relative to the calendar, never a URL): their dated milestones
become all-day events, tagged `milestone`, in the language of the page; with the roadmap's
`ics: { items: true }`, its dated items too. Their ids are prefixed with the roadmap's slug
(`product.v1`), and an undated milestone does not cross.

```md title="course.md"
---
title: Lorem Course
format: calendar
lang: en
timezone: Europe/Paris
view: agenda
include: [../roadmap-product/product.md]
---
```

A calendar can be made of `include:` only, with an empty body: calendar.recit.dev shows the releases
of Récit this way, from the roadmap of Récit.

### To a webstory and to an atlas

`recit convert meetups.md --to webstory` tells the next occurrences as an "upcoming" story: a title
card, then one card per occurrence with its title, its date in the calendar's zone and language, its
place and a link to its page. `recit convert meetups.md --to atlas` puts the events whose place has
a `geo` on a map, an overview then one view per event ahead; an address is never geocoded. Both
compile the calendar as `recit build` does, write Markdown by default (`-o story.json` for the twin)
and refuse a calendar with nothing to show, with nothing written.

### Places from a directory

`places: ./places.md` names a `directory` story: `location=@dolor-hall` then takes the name, the
address and the `geo` of that entry, the same place on every event and in the JSON-LD.

## In a site

A site publishes a calendar like any story (`publish:`), at `/<routePrefix>/<slug>`, and **a page
per event** at `/<routePrefix>/<slug>/<id>`: its dates, its place, its description, its deck or
film, "Subscribe" for that event alone, and its `schema.org/Event` JSON-LD for search engines. In an
MDX page:

```mdx
<StoryEmbed slug="meetups" view="agenda" />
<UpcomingEvents slug="meetups" count={3} />
```

`UpcomingEvents` counts from the reader's clock once the page is loaded, so a site built on Monday
does not show Monday's event as upcoming on Tuesday.

On the fullscreen pages of a site (`publish.layout: "none"`), the calendar's and each event's, a
"Back to the site" link above the title leads to the site's home in the calendar's language; an
event page keeps its own "Back to the calendar" under it. An embedded calendar has none.

A calendar opens on the month of the build day when that month has an event. Otherwise it opens on
the month of the next event, or, for a calendar that only holds past events (releases, a finished
season), on the month of the last one: it never opens on an empty month. `?date=` in the address,
and the `date` of the `Calendar` component, still choose the date shown first; "Today" goes back to
the build day.

## Packages

```ts
import { compileStory } from "@recit/core";
import { storyToCalendar } from "@recit/calendar";

const story = await compileStory(markdown, { file: "meetups.md" });
const { calendar, diagnostics } = storyToCalendar(story);
```

| Import                       | Contents                                                                                         |
| ---------------------------- | ------------------------------------------------------------------------------------------------ |
| `@recit/calendar`            | `storyToCalendar`, `expandEvents`, `calendarIcs`, `roadmapCalendarEvents`, the model             |
| `@recit/calendar/components` | the views (`Calendar`, `MonthView`, `AgendaList`, `EventCard`…) and `calendarStrings`            |
| `@recit/calendar/runtime`    | `mountCalendar`, the page of `recit dev` and `recit build`                                       |
| `@recit/calendar/styles.css` | the stylesheet of the views                                                                      |
| `@recit/calendar/node`       | `includedRoadmaps`, `calendarPlaces`: the joins with a roadmap and a directory (Node)            |
| `@recit/time`                | the wall times, zones and recurrences the calendar and the roadmap share                         |
| `@recit/time/calendar`       | the calendar model (`Calendar`, `CalendarEvent`, `Occurrence`), re-exported by `@recit/calendar` |

### Joins in Node

`@recit/calendar/node` holds the two joins of a calendar, `includedRoadmaps` (the dated milestones
of the roadmaps of `include:`) and `calendarPlaces` (the places of its `places` directory). The
calendar depends on neither format: the caller reads them. A roadmap reader, with public names only
(the one of `recit build` is not exported):

```ts
import { includedRoadmaps, type ReadRoadmap } from "@recit/calendar/node";
import { loadStory } from "@recit/cli";
import { compileStory, hasErrors, resolveRoadmapSettings } from "@recit/core";
import { roadmapSettings, storyToRoadmap } from "@recit/roadmap";

const readRoadmap: ReadRoadmap = async (file, { locale, today }) => {
  const loaded = loadStory(file, locale ? { locale } : {});
  const story = await compileStory(loaded.input, { syntax: loaded.syntax, file: loaded.file });
  const { roadmap, diagnostics } = await storyToRoadmap(story, today ? { today } : {});
  if (hasErrors(diagnostics)) return { ok: false, diagnostics };
  return {
    ok: true,
    roadmap,
    items: resolveRoadmapSettings(roadmapSettings(story)).ics.items,
    watchFiles: loaded.paths,
  };
};

// `meetups` is the compiled calendar story: its front matter names the roadmaps
const { events, diagnostics } = await includedRoadmaps("meetups.md", meetups, { readRoadmap });
```

`calendarPlaces(file, places, { loadStory, directoryPlaces })` takes `loadStory` of `@recit/cli` and
`directoryPlaces` of `@recit/directory`. The reader is tested as written.

## MCP

`describe_format` explains the format, `validate_story` checks a calendar, and `expand_events` gives
the occurrences of a story in a window and a zone, so that an agent checks a rule before it writes
it. The guide is `recit://guide/calendar`.
