Skip to content

Commit

Permalink
fix: Project type specific guessing of partials. (#215)
Browse files Browse the repository at this point in the history
fixes #213
  • Loading branch information
Zoramite committed Aug 6, 2021
1 parent 527de65 commit ef7920d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ts/projectType/amagaki/amagakiAutoFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,19 @@ export class AmagakiAutoFields extends LiveEditorAutoFields {

return super.deepGuessObject(data, keyBase);
}

/**
* Guess the type of field to use based on the key and value.
*
* @param key Key to guess the type of field.
* @param data Data to use for guessing field type.
*/
guessType(key: string, data: any): string {
// Check for partials field.
if (key === 'partials' && DataType.isArray(data)) {
return 'partials';
}

return super.guessType(key, data);
}
}
15 changes: 15 additions & 0 deletions src/ts/projectType/grow/growAutoFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,19 @@ export class GrowAutoFields extends LiveEditorAutoFields {

return super.deepGuessObject(data, keyBase);
}

/**
* Guess the type of field to use based on the key and value.
*
* @param key Key to guess the type of field.
* @param data Data to use for guessing field type.
*/
guessType(key: string, data: any): string {
// Check for partials field.
if (key === 'partials' && DataType.isArray(data)) {
return 'partials';
}

return super.guessType(key, data);
}
}

0 comments on commit ef7920d

Please sign in to comment.