forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.ts
65 lines (64 loc) · 2.2 KB
/
schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { list } from '@keystone-6/core'
import { select, relationship, text, timestamp } from '@keystone-6/core/fields'
import { document } from '@keystone-6/fields-document'
import { allowAll } from '@keystone-6/core/access'
export const lists = {
Post: list({
access: allowAll,
fields: {
title: text({ validation: { isRequired: true } }),
slug: text({ isIndexed: 'unique', validation: { isRequired: true } }),
status: select({
type: 'enum',
options: [
{ label: 'Draft', value: 'draft' },
{ label: 'Published', value: 'published' },
],
}),
content: document({
// We want to have support a fully featured document editor for our
// authors, so we're enabling all of the formatting abilities and
// providing 1, 2 or 3 column layouts.
formatting: true,
dividers: true,
links: true,
layouts: [
[1, 1],
[1, 1, 1],
],
// We want to support twitter-style mentions in blogs, so we add an
// inline relationship which references the `Author` list.
relationships: {
mention: {
listKey: 'Author',
label: 'Mention', // This will display in the Admin UI toolbar behind the `+` icon
selection: 'id name', // These fields will be available to the renderer
},
},
}),
publishDate: timestamp(),
author: relationship({ ref: 'Author.posts', many: false }),
},
}),
Author: list({
access: allowAll,
fields: {
name: text({ validation: { isRequired: true } }),
email: text({ isIndexed: 'unique', validation: { isRequired: true } }),
posts: relationship({ ref: 'Post.author', many: true }),
bio: document({
// We want to constrain the formatting in Author bios to a limited set of options.
// We will allow bold, italics, unordered lists, and links.
// See the document field guide for a complete list of configurable options
formatting: {
inlineMarks: {
bold: true,
italic: true,
},
listTypes: { unordered: true },
},
links: true,
}),
},
}),
}