Can you use multiple fields as sources when generating a slug in Sanity?

2 replies
Last updated: Apr 24, 2020
Is it possible to provide more than one field as a source when generating a slug? Something like
source: "title && date"
Apr 24, 2020, 1:42 PM
You can do a function for `source`:
source: doc => `${doc.title} ${doc.date}`
Apr 24, 2020, 2:25 PM
The value you return from that should be the actual value that gets slugified – not the name of the field as a string.
Apr 24, 2020, 2:26 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?