|
1 | 1 | const authorFields = [ |
2 | | - { |
3 | | - id: 'name', |
4 | | - name: 'Name', |
5 | | - type: 'Symbol', |
6 | | - required: true |
7 | | - }, |
8 | | - { |
9 | | - id: 'title', |
10 | | - name: 'Title', |
11 | | - type: 'Symbol', |
12 | | - required: true |
13 | | - }, |
14 | | - { |
15 | | - id: 'company', |
16 | | - name: 'Company', |
17 | | - type: 'Symbol', |
18 | | - required: true |
19 | | - }, |
20 | | - { |
21 | | - id: 'shortBio', |
22 | | - name: 'Short Bio', |
23 | | - type: 'Text', |
24 | | - required: true |
25 | | - }, |
26 | | - { |
27 | | - id: 'email', |
28 | | - name: 'Email', |
29 | | - type: 'Symbol', |
30 | | - required: true |
31 | | - }, |
32 | | - { |
33 | | - id: 'twitter', |
34 | | - name: 'Twitter', |
35 | | - type: 'Symbol', |
36 | | - required: true |
37 | | - } |
| 2 | + { |
| 3 | + id: 'name', |
| 4 | + name: 'Name', |
| 5 | + type: 'Symbol', |
| 6 | + required: true |
| 7 | + }, |
| 8 | + { |
| 9 | + id: 'title', |
| 10 | + name: 'Title', |
| 11 | + type: 'Symbol', |
| 12 | + required: true |
| 13 | + }, |
| 14 | + { |
| 15 | + id: 'company', |
| 16 | + name: 'Company', |
| 17 | + type: 'Symbol', |
| 18 | + required: true |
| 19 | + }, |
| 20 | + { |
| 21 | + id: 'shortBio', |
| 22 | + name: 'Short Bio', |
| 23 | + type: 'Text', |
| 24 | + required: true |
| 25 | + }, |
| 26 | + { |
| 27 | + id: 'email', |
| 28 | + name: 'Email', |
| 29 | + type: 'Symbol', |
| 30 | + required: true |
| 31 | + }, |
| 32 | + { |
| 33 | + id: 'twitter', |
| 34 | + name: 'Twitter', |
| 35 | + type: 'Symbol', |
| 36 | + required: true |
| 37 | + } |
38 | 38 | ]; |
39 | 39 |
|
40 | 40 | const blogFields = [ |
41 | | - { |
42 | | - id: 'title', |
43 | | - name: 'Title', |
44 | | - type: 'Symbol', |
45 | | - required: true |
46 | | - }, |
47 | | - { |
48 | | - id: 'slug', |
49 | | - name: 'Slug', |
50 | | - type: 'Symbol', |
51 | | - required: true |
52 | | - }, |
53 | | - { |
54 | | - id: 'heroImage', |
55 | | - name: 'Hero Image', |
56 | | - type: 'Object', |
57 | | - required: true |
58 | | - }, |
59 | | - { |
60 | | - id: 'description', |
61 | | - name: 'Description', |
62 | | - type: 'Text', |
63 | | - required: true |
64 | | - }, |
65 | | - { |
66 | | - id: 'body', |
67 | | - name: 'Body', |
68 | | - type: 'Text', |
69 | | - required: true |
70 | | - }, |
71 | | - { |
72 | | - id: 'author', |
73 | | - name: 'Author', |
74 | | - type: 'Link', |
75 | | - required: true, |
76 | | - linkType: 'Entry', |
77 | | - validations: [{linkContentType: ['author']}] |
78 | | - }, |
79 | | - { |
80 | | - id: 'publishedDate', |
81 | | - name: 'Published Date', |
82 | | - type: 'Date', |
83 | | - required: true |
84 | | - }, |
85 | | - { |
86 | | - id: 'tags', |
87 | | - name: 'Tags', |
88 | | - type: 'Link', |
89 | | - required: true, |
90 | | - linkType: 'Array', |
91 | | - validations: [{linkContentType: ['tag']}] |
92 | | - }, |
| 41 | + { |
| 42 | + id: 'title', |
| 43 | + name: 'Title', |
| 44 | + type: 'Symbol', |
| 45 | + required: true |
| 46 | + }, |
| 47 | + { |
| 48 | + id: 'slug', |
| 49 | + name: 'Slug', |
| 50 | + type: 'Symbol', |
| 51 | + required: true |
| 52 | + }, |
| 53 | + { |
| 54 | + id: 'heroImage', |
| 55 | + name: 'Hero Image', |
| 56 | + type: 'Object', |
| 57 | + required: true |
| 58 | + }, |
| 59 | + { |
| 60 | + id: 'description', |
| 61 | + name: 'Description', |
| 62 | + type: 'Text', |
| 63 | + required: true |
| 64 | + }, |
| 65 | + { |
| 66 | + id: 'body', |
| 67 | + name: 'Body', |
| 68 | + type: 'Text', |
| 69 | + required: true |
| 70 | + }, |
| 71 | + { |
| 72 | + id: 'author', |
| 73 | + name: 'Author', |
| 74 | + type: 'Link', |
| 75 | + required: true, |
| 76 | + linkType: 'Entry', |
| 77 | + validations: [{ linkContentType: ['author'] }] |
| 78 | + }, |
| 79 | + { |
| 80 | + id: 'publishedDate', |
| 81 | + name: 'Published Date', |
| 82 | + type: 'Date', |
| 83 | + required: true |
| 84 | + }, |
| 85 | + { |
| 86 | + id: 'tags', |
| 87 | + name: 'Tags', |
| 88 | + type: 'Link', |
| 89 | + required: true, |
| 90 | + linkType: 'Array', |
| 91 | + validations: [{ linkContentType: ['tag'] }] |
| 92 | + } |
93 | 93 | ]; |
94 | 94 |
|
95 | 95 | const tagFields = [ |
96 | | - { |
97 | | - id: 'name', |
98 | | - name: 'Name', |
99 | | - type: 'Symbol', |
100 | | - required: true |
101 | | - }, |
| 96 | + { |
| 97 | + id: 'name', |
| 98 | + name: 'Name', |
| 99 | + type: 'Symbol', |
| 100 | + required: true |
| 101 | + } |
102 | 102 | ]; |
103 | 103 |
|
104 | | -module.exports = function (migration, context) { |
105 | | - const tag = migration.createContentType('tag', { |
106 | | - name: 'Tag', |
107 | | - description: 'tag' |
108 | | - }); |
109 | | - |
110 | | - tagFields.forEach(field => { |
111 | | - tag.createField(field.id, { |
112 | | - name: field.name, |
113 | | - type: field.type, |
114 | | - required: field.required |
115 | | - }); |
116 | | - }); |
| 104 | +module.exports = function(migration, context) { |
| 105 | + const tag = migration.createContentType('tag', { |
| 106 | + name: 'Tag', |
| 107 | + description: 'tag' |
| 108 | + }); |
117 | 109 |
|
118 | | - const author = migration.createContentType('author', { |
119 | | - name: 'Author', |
120 | | - description: 'Author of Blogpost' |
| 110 | + tagFields.forEach(field => { |
| 111 | + tag.createField(field.id, { |
| 112 | + name: field.name, |
| 113 | + type: field.type, |
| 114 | + required: field.required |
121 | 115 | }); |
| 116 | + }); |
122 | 117 |
|
123 | | - authorFields.forEach(field => { |
124 | | - author.createField(field.id, { |
125 | | - name: field.name, |
126 | | - type: field.type, |
127 | | - required: field.required |
128 | | - }); |
129 | | - }); |
130 | | - const blog = migration.createContentType('blogPost', { |
131 | | - name: 'BlogPost', |
132 | | - description: 'Blog Post' |
133 | | - }); |
| 118 | + const author = migration.createContentType('author', { |
| 119 | + name: 'Author', |
| 120 | + description: 'Author of Blogpost' |
| 121 | + }); |
134 | 122 |
|
135 | | - blogFields.forEach(field => { |
136 | | - if (!field.linkType) { |
137 | | - blog.createField(field.id, { |
138 | | - name: field.name, |
139 | | - type: field.type, |
140 | | - required: field.required |
141 | | - }); |
142 | | - } else { |
143 | | - blog.createField(field.id, { |
144 | | - name: field.name, |
145 | | - type: field.type, |
146 | | - linkType: field.linkType, |
147 | | - required: field.required, |
148 | | - validations: field.validations |
149 | | - }); |
150 | | - } |
| 123 | + authorFields.forEach(field => { |
| 124 | + author.createField(field.id, { |
| 125 | + name: field.name, |
| 126 | + type: field.type, |
| 127 | + required: field.required |
151 | 128 | }); |
| 129 | + }); |
| 130 | + const blog = migration.createContentType('blogPost', { |
| 131 | + name: 'BlogPost', |
| 132 | + description: 'Blog Post' |
| 133 | + }); |
152 | 134 |
|
153 | | - |
| 135 | + blogFields.forEach(field => { |
| 136 | + if (!field.linkType) { |
| 137 | + blog.createField(field.id, { |
| 138 | + name: field.name, |
| 139 | + type: field.type, |
| 140 | + required: field.required |
| 141 | + }); |
| 142 | + } else { |
| 143 | + blog.createField(field.id, { |
| 144 | + name: field.name, |
| 145 | + type: field.type, |
| 146 | + linkType: field.linkType, |
| 147 | + required: field.required, |
| 148 | + validations: field.validations |
| 149 | + }); |
| 150 | + } |
| 151 | + }); |
154 | 152 | }; |
0 commit comments