mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-08-07 01:13:08 +02:00
#707 - Fix clearempty
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
- [#699](https://github.com/estruyf/vscode-front-matter/issues/699): Changing border theme variable for the dashboard header
|
||||
- [#703](https://github.com/estruyf/vscode-front-matter/issues/703): Fix retrieval of Astro Collections for `pnpm` projects
|
||||
- [#704](https://github.com/estruyf/vscode-front-matter/issues/704): Fix `zod` schema script for optional fields
|
||||
- [#707](https://github.com/estruyf/vscode-front-matter/issues/707): Fix `clearEmpty` issue with `draft` and `boolean` fields which are by default set to `true`
|
||||
|
||||
## [9.3.1] - 2023-10-27
|
||||
|
||||
|
||||
@@ -257,9 +257,18 @@ export class DataListener extends BaseListener {
|
||||
}
|
||||
|
||||
const contentType = ArticleHelper.getContentType(article);
|
||||
const sourceField = ContentType.findFieldByName(contentType.fields, field);
|
||||
|
||||
if (!value && field !== titleField && contentType.clearEmpty) {
|
||||
value = undefined;
|
||||
// Check if the draft or boolean field needs to be cleared
|
||||
// This is only required when the default value is not set to true
|
||||
if (sourceField && (sourceField.type === 'draft' || sourceField.type === 'boolean')) {
|
||||
if (!sourceField.default) {
|
||||
value = undefined;
|
||||
}
|
||||
} else {
|
||||
value = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const dateFields = ContentType.findFieldsByTypeDeep(contentType.fields, 'datetime');
|
||||
|
||||
Reference in New Issue
Block a user