FieldsText, number and date

Text, number, date and time

The plain values: a line of text, a number, a date, a date with a time, and the slug that becomes part of an entry's URL.

View as Markdown

Text

f.text() is a single line. .max(n) limits it in characters, and publish enforces the limit. There is no multi-line text field: paragraphs are richtext, which keeps formatting as data rather than as line breaks.

components/elements/Cta.schema.ts
  fields: {
    heading: f.text().max(80),
    text: f.text().max(200).optional(),
    label: f.text().max(40),
    href: f.link(),
  },

Text is the one field editors can change in place in the canvas, when its element carries a mark.

Number

f.number() shows a number box and stores a number. An empty box stores nothing, so an optional number is undefined in the view, not 0.

Date and time

f.date() is a calendar: a text box the editor may type into, and a calendar button that opens a month grid. It stores the day as 2026-09-02, and publish refuses anything else — 2.9.2026 or a February 30th never reach the site. The view formats it for the reader; the starter formats in the page's language:

components/articles.ts
export const formatDate = (iso: string, locale: string) =>
  new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" }).format(new Date(iso));

f.datetime() is the same calendar with an hour and a minute beside it. It stores a moment in time as a UTC instant, 2026-09-02T14:30:00Z, so an event start or a publish-at means the same thing in every zone and sorts as a string. The editor picks in the site's time zone, and a hint under the field names it.

The site's zone is one line of config, an IANA name:

smoodly/config.ts
export const config = defineConfig({
  // …
  locales: { default: routing.defaultLocale, supported: [...routing.locales] },
  // Editors pick dates and times in this zone; the views format with it (an IANA name, never an offset).
  timeZone: "Europe/Helsinki",
  // …
});

Name a city, never an offset. "+3" is wrong half the year; Europe/Helsinki carries the daylight-saving rules, and the browser and Node apply them from their own zone database. defineConfig refuses a name the runtime does not know. Without timeZone, editors pick in their own browser's zone, and the hint says so.

A view formats a datetime with the same zone:

components/articles.ts
export const formatDateTime = (iso: string, locale: string, timeZone: string) =>
  new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short", timeZone }).format(new Date(iso));

Pass config.timeZone from your config file. A collection can order its entries by either field, as the starter's articles do with order: { by: "date", direction: "desc" }.

Time zones in Europe

The value to put in timeZone, country by country. A country with several zones has its capital first.

CountrytimeZone
AlbaniaEurope/Tirane
AndorraEurope/Andorra
AustriaEurope/Vienna
BelarusEurope/Minsk
BelgiumEurope/Brussels
Bosnia and HerzegovinaEurope/Sarajevo
BulgariaEurope/Sofia
CroatiaEurope/Zagreb
CyprusAsia/Nicosia
CzechiaEurope/Prague
DenmarkEurope/Copenhagen
EstoniaEurope/Tallinn
Faroe IslandsAtlantic/Faroe
FinlandEurope/Helsinki
ÅlandEurope/Mariehamn
FranceEurope/Paris
GermanyEurope/Berlin (Büsingen: Europe/Busingen)
GibraltarEurope/Gibraltar
GreeceEurope/Athens
GuernseyEurope/Guernsey
HungaryEurope/Budapest
IcelandAtlantic/Reykjavik
IrelandEurope/Dublin
Isle of ManEurope/Isle_of_Man
ItalyEurope/Rome
JerseyEurope/Jersey
KosovoEurope/Belgrade
LatviaEurope/Riga
LiechtensteinEurope/Vaduz
LithuaniaEurope/Vilnius
LuxembourgEurope/Luxembourg
MaltaEurope/Malta
MoldovaEurope/Chisinau
MonacoEurope/Monaco
MontenegroEurope/Podgorica
NetherlandsEurope/Amsterdam
North MacedoniaEurope/Skopje
NorwayEurope/Oslo (Svalbard: Arctic/Longyearbyen)
PolandEurope/Warsaw
PortugalEurope/Lisbon (Azores: Atlantic/Azores, Madeira: Atlantic/Madeira)
RomaniaEurope/Bucharest
RussiaEurope/Moscow (also Europe/Kaliningrad, Europe/Samara, Europe/Astrakhan, Europe/Saratov, Europe/Ulyanovsk, Europe/Volgograd, Europe/Kirov)
San MarinoEurope/San_Marino
SerbiaEurope/Belgrade
SlovakiaEurope/Bratislava
SloveniaEurope/Ljubljana
SpainEurope/Madrid (Canary Islands: Atlantic/Canary)
SwedenEurope/Stockholm
SwitzerlandEurope/Zurich
TurkeyEurope/Istanbul
UkraineEurope/Kyiv (Crimea: Europe/Simferopol)
United KingdomEurope/London
Vatican CityEurope/Vatican

Outside Europe the same rule holds — a city name from the IANA database, such as America/New_York or Asia/Tokyo. The full list is Intl.supportedValuesOf("timeZone") in any modern runtime.

Slug

f.slug() is a text box shown with the entry's URL prefix in front, such as /posts/. It belongs on a collection, and the field must be named slug: that is the name the URL is built from, so collection() refuses f.slug() under any other name.

smoodly/collections.ts
export const articles = smoodly.collection({
  name: "articles",
  title: "Articles",
  titleField: "title",
  path: { en: "posts", fi: "artikkelit" },
  // …
  fields: {
    title: f.text().localized(),
    // …
    slug: f.slug({ from: "title" }),
    // …
  },
});

The starter passes from: "title": the admin fills the slug from the title as the editor types it, until they type a slug of their own. It stops at the first publish, so a live URL never changes by itself. A slug is tidied when the box loses focus, so Hello World becomes hello-world, and publish refuses anything that is still not a valid slug. A slug is per language without .localized(), because each language has its own URL. Two entries under the same parent cannot share one. Pages have no slug field: a page's slug is set in the admin when it is created and renamed under Settings.

Next, Richtext and elements.

Edit this page on GitHubLast updated 3 Oct 2026