Clarification on configuring the calendar integration in Sanity.io.
14 replies
Last updated: Sep 16, 2021
G
Hi all, I am looking at integrating the calendar https://www.sanity.io/plugins/content-calendar and I am stuck at the configuration in
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
config/content-calendar.json, specifically
"types": [ { "type": "post", "field": "publishedAt", "titleField": "title" } ],
https://www.sanity.io/blog/calendar-plugin
Sep 16, 2021, 4:15 PM
Hi Gibson.
To answer your follow-up question—yes, the
typeswill be an array of objects, with each object providing a
typeproperty (which document to display on the calendar), a
fieldproperty (which field to use from the aforementioned document to get the date for the calendar), and a
titleFieldproperty (which field to use from the aforementioned document to display a title on the calendar).
To answer your follow-up question—yes, the
typeproperty should match the
nameproperty from your document schema.
Sep 16, 2021, 4:26 PM
G
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”
}
],
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
G
am i correct?
Sep 16, 2021, 4:29 PM
G
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
G
ah, i see
Sep 16, 2021, 4:33 PM
G
i there no mention of explicitly needed to create a
publishedAtfield as i thought each document has an implicit
publishedAtfield which is linked to the
Publishbutton
Sep 16, 2021, 4:34 PM
G
great, that works for me. Thanks
user A
Sep 16, 2021, 4:36 PM
G
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. 🙂
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
G
great, that works for me. Thanks
user A
Sep 16, 2021, 4:36 PM
G
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.