🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Clarification on configuring the calendar integration in Sanity.io.

14 replies
Last updated: Sep 16, 2021
Hi all, I am looking at integrating the calendar https://www.sanity.io/plugins/content-calendar and I am stuck at the configuration in
config/content-calendar.json
, specifically

"types": [
    {
      "type": "post",
      "field": "publishedAt",
      "titleField": "title"
    }
  ],
does type mean something like ‘document’ and what is the purpose of ‘titleField’ as there was no mention of it in
https://www.sanity.io/blog/calendar-plugin
Sep 16, 2021, 4:15 PM
Hi Gibson.
types
will be an array of objects, with each object providing a
type
property (which document to display on the calendar), a
field
property (which field to use from the aforementioned document to get the date for the calendar), and a
titleField
property (which field to use from the aforementioned document to display a title on the calendar).
To answer your follow-up question—yes, the
type
property should match the
name
property from your document schema.
Sep 16, 2021, 4:26 PM
Thanks, Geoff. So that means if my schema is this
export default {
title: ‘Careers’,
name: ‘careers’,
type: ‘document’,
fields: [
{
title: ‘Header’,
name: ‘header’,
type: ‘string’,
validation: (Rule) => Rule.required(),
}
]
};

So my configuration for the calendar content will be
“types”: [
{
“type”: “careers”,
“field”: “publishedAt”,
“titleField”: “header”
}
],
Sep 16, 2021, 4:29 PM
am i correct?
Sep 16, 2021, 4:29 PM
As long as
careers
has a
publishedAt
field, then yes, that looks correct. 👍
Sep 16, 2021, 4:30 PM
ok, so i need to explicitly put a publishedAt field for all documents which i want to link to the calendar?
Sep 16, 2021, 4:30 PM
Given
"field": "publishedAt",
, yes you do. You could name it whatever you want, but then would want to update your calendar config file to match.
Sep 16, 2021, 4:32 PM
Given
"field": "publishedAt",
, yes you do. You could name it whatever you want, but then would want to update your calendar config file to match.
Sep 16, 2021, 4:32 PM
ah, i see
Sep 16, 2021, 4:33 PM
i there no mention of explicitly needed to create a
publishedAt
field as i thought each document has an implicit
publishedAt
field which is linked to the
Publish
button
Sep 16, 2021, 4:34 PM
great, that works for me. Thanks
user A
Sep 16, 2021, 4:36 PM
great, that works for me. Thanks
user A
Sep 16, 2021, 4:36 PM
That’s a fair assumption. Apologies it’s not clearer. I’ll see about getting those two documents updated to point this out explicitly.
For your own Sanity journey, any fields starting with an underscore are added by Sanity. Anything else is specified in a schema. That’s
sort of alluded to here but could be clearer and I certainly wouldn’t expect you to peruse all the docs before diving in. We’ll work on this. Thanks for pointing this out and please continue to reach out. 🙂
Sep 16, 2021, 4:41 PM
great, that works for me. Thanks
user A
Sep 16, 2021, 4:36 PM
thanks a lot, Geoff, your explanation cleared up a lot of things
Sep 16, 2021, 5:10 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?