#306 - Default value fix

This commit is contained in:
Elio Struyf
2022-04-04 08:35:18 +02:00
parent 8d5a678bb8
commit f059b89fa5
3 changed files with 10 additions and 3 deletions
+1
View File
@@ -21,6 +21,7 @@
- [#302](https://github.com/estruyf/vscode-front-matter/issues/302): Fix for spinner when navigating between tabs
- [#304](https://github.com/estruyf/vscode-front-matter/issues/304): Fix yaml stringify which caused additional fields to be added
- [#305](https://github.com/estruyf/vscode-front-matter/issues/305): Fix for overflow issue in taxonomy picker
- [#306](https://github.com/estruyf/vscode-front-matter/issues/306): Fix for default value of content type fields
## [7.0.0] - 2022-03-21 - [Release notes](https://beta.frontmatter.codes/updates/v7.0.0)
+1 -1
View File
@@ -748,7 +748,7 @@
"description": "Title to show in the UI"
},
"default": {
"type": "string",
"type": ["string", "number", "boolean", "array", "object", "null"],
"description": "Default value"
},
"choices": {
+8 -2
View File
@@ -152,8 +152,14 @@ export class ContentType {
if (field.type === "fields") {
data[field.name] = this.processFields(field, titleValue, {});
} else {
data[field.name] = field.default ? processKnownPlaceholders(field.default, titleValue, dateFormat) : "";
data[field.name] = field.default ? ArticleHelper.processCustomPlaceholders(data[field.name], titleValue) : "";
const defaultValue = field.default;
if (typeof defaultValue === "string") {
data[field.name] = processKnownPlaceholders(defaultValue, titleValue, dateFormat);
data[field.name] = ArticleHelper.processCustomPlaceholders(data[field.name], titleValue);
} else {
data[field.name] = typeof defaultValue !== "undefined" ? defaultValue : "";
}
}
}
}