Knut Melvær
Knut is a principal developer marketing manager at Sanity.io
Simple content type for a question and answer pattern
// faq.js
export default {
name: 'faq',
type: 'object',
title: 'Frequently asked question',
fields: [
{
name: 'question',
type: 'string',
title: 'Question'
},
{
name: 'answer',
type: 'text',
title: 'Answer',
}
]
}// helpArticle.js
export default {
name: 'helpArticle',
type: 'document',
title: 'Help article',
fields: [
{
name: 'title',
type: 'string',
title: 'Title'
},
{
name: 'faqs',
type: 'array',
title: 'Frequently Asked Questions',
of: [
{
type: 'faq'
}
]
}
]
}// First, we must import the schema creator
import createSchema from 'part:@sanity/base/schema-creator';
// Then import schema types from any plugins that might expose them
import schemaTypes from 'all:part:@sanity/base/schema-type';
// other imports
// ...
import faq from './faq'
export default createSchema({
name: 'default',
types: schemaTypes.concat([
// ... other types,
faq
])
})If you import this schema into schemas.js, then you can use this pattern as type: 'faq' elsewhere.
Knut is a principal developer marketing manager at Sanity.io
Automatically track when content was first published with a timestamp that sets once and never overwrites, providing reliable publication history for analytics and editorial workflows.
Go to First Published Timestamp FunctionAI-powered automatic tagging for Sanity blog posts that analyzes content to generate 3 relevant tags, maintaining consistency by reusing existing tags from your content library.
Go to Automatically tag blog postsThis can be used for blogs or articles where you want to possibly display next and previous article buttons
Go to Get current post, previous post, and next postHow to automatically generate linked headings with a custom serializer
Go to Anchored Headings for Portable Text