@ctkit/core
v0.2.0
Published
Types, constants, and validators for defining Contentful content models with ctkit
Maintainers
Readme
@ctkit/core
Types, constants, and validators for defining Contentful content models with ctkit.
Installation
npm install @ctkit/coreIf you install
@ctkit/cli, core is included automatically as a dependency.
Usage
import {
ContentTypeSchema,
FieldType,
LinkType,
Mark,
NodeType,
MimeType,
validators,
richTextValidators,
} from '@ctkit/core';
const blogPost: ContentTypeSchema = {
id: 'blogPost',
name: 'Blog Post',
displayField: 'title',
fields: [
{
id: 'title',
name: 'Title',
type: FieldType.Symbol,
required: true,
validations: [validators.textLength(1, 200)],
},
{
id: 'body',
name: 'Body',
type: FieldType.RichText,
required: true,
validations: [
richTextValidators.allowedMarks([Mark.Bold, Mark.Italic]),
richTextValidators.allowedNodeTypes([
NodeType.Heading2, NodeType.Paragraph, NodeType.Hyperlink,
]),
],
},
],
};What's included
- Types —
ContentTypeSchema,Field, all field type interfaces, validation interfaces - Constants —
FieldType,LinkType,Mark,NodeType,MimeType,Widget - Validators —
validators.*,richTextValidators.*,commonFields.*
Documentation
See ctkit.dev for full documentation.
