Knut Melvær
Knut is a principal developer marketing manager at Sanity.io
Knut is located at Oslo, Norway
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
This 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 TextMigration script to convert plain text to block content across your content lake
Go to Migrate plain text field to Portable TextSchemas for adding richer quotes within Portable Text
Go to Rich quotations in Portable Text