Infer format from extension for new entries.
If a collection has no format specified, we try to infer the format from the file extension when reading. This commit also allows us to infer the format from the `extension` set in the config, so that we can still create the correct format when making a new file.
This commit is contained in:
parent
0e51cff231
commit
864083bc8b
@ -47,6 +47,13 @@ export function resolveFormat(collectionOrEntity, entry) {
|
||||
return formatByExtension(fileExtension);
|
||||
}
|
||||
|
||||
// If creating a new file, and an `extension` is specified in the
|
||||
// collection config, infer the format from that extension.
|
||||
const extension = collectionOrEntity.get('extension');
|
||||
if (extension) {
|
||||
return formatByExtension(extension);
|
||||
}
|
||||
|
||||
// If no format is specified and it cannot be inferred, return the default.
|
||||
return formatByName();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user