Collections
A collection in Imput is an assortment of content that all shares the same shape.
- All
postshave both a title and an author - All
authorshave an email and an email address - And so on...
Add a collection
Collections are added to cms' settings like everything else, you can define collections like this:
const CMS = () => (
<ImputCMS
{...{
settings: {
// your collections go in here!
collections: [],
}
}}
/>
)Let's add the most bare-bones configuration for adding new pages. Your config will look something like this:
const CMS = () => (
<ImputCMS
{...{
settings: {
collections: [
{
name: 'page',
label: 'Page',
folder: 'content/pages',
create: true,
slug: '{{title}}',
extension: 'mdx',
fields: [
{ label: 'Title', name: 'title', widget: 'string' },
{ label: 'Content', name: 'body', widget: 'markdown' },
],
},
],
}
}}
/>
)nameshould be considered a unique id for your collectionlabelshould be a readable string that describes your collection (e.g. "Blog", "Pages", etc.)folderis where your files will be saved and updated in your repositorycreatewhether new content can be created for this collectionslugis how Imput will generate your new content's filename (add link to slug page here)extensioneither "md" or "mdx", the file extension Imput will create your new content infieldsthis is your collection schema, in the example above our content will have atitleand abodyvalue
That's the bare minimum config! There's a lot more to collections but we'll go over it later. Next up, writing your first content.