Skip to content

Commit b7230cd

Browse files
committed
fix(templates): populate preview template schema
1 parent 10f3a06 commit b7230cd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/utils/templates.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ export const previewTemplate = (collections: ResolvedCollection[], gitInfo: GitI
195195
filename: moduleTemplates.preview,
196196
getContents: ({ options }: { options: { collections: ResolvedCollection[] } }) => {
197197
const collectionsMeta = options.collections.reduce((acc, collection) => {
198+
const schemaWithCollectionName = {
199+
...collection.extendedSchema,
200+
definitions: {
201+
[collection.name]: collection.extendedSchema.definitions['__SCHEMA__'],
202+
},
203+
}
198204
acc[collection.name] = {
199205
name: collection.name,
200206
pascalName: pascalCase(collection.name),
@@ -203,7 +209,7 @@ export const previewTemplate = (collections: ResolvedCollection[], gitInfo: GitI
203209
source: collection.source?.filter(source => source.repository ? undefined : collection.source) || [],
204210
type: collection.type,
205211
fields: collection.fields,
206-
schema: collection.schema,
212+
schema: schemaWithCollectionName,
207213
tableDefinition: generateCollectionTableDefinition(collection),
208214
}
209215
return acc

0 commit comments

Comments
 (0)