Index
Edit

Slug

A slug is a unique string (typically a normalized version of title or other representative string), often used as part of a URL. The input form will render an error message if the current slug field not unique.

Properties

  • optionsobject - Extra type options. See below.

Options

  • sourcestring - Which other field the slug value is derived from. If set, the the slug field will change whenever the user updates the source field. If unset, the slug value must be manually input by the user.
  • maxLengthnumber - Max number of characters the slug may contain. Defaults to 200
  • slugifyfunction - Supply a custom override function which handles string normalisation. If slugify is set, the maxLength option is ignored.

Example

{
  title: 'Slug',
  name: 'slug',
  type: 'slug',
  options: {
    source: 'title',
    maxLength: 200, // will be ignored if slugify is set
    slugify: input => input
                         .toLowerCase()
                         .replace(/\s+/g, '-')
                         .slice(0, 200)
  }
}

Example output data

{
  "_type": "slug",
  "auto": true,
  "current": "this-is-the-title"
}

Previous: GeopointNext: Image