mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-06-23 03:24:59 +02:00
#385: Add a default draft field value
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
- [#370](https://github.com/estruyf/vscode-front-matter/issues/370): Define the tags and categories as reserved keywords for custom taxonomy
|
||||
- [#372](https://github.com/estruyf/vscode-front-matter/issues/372): Rename Taxonomy tab to Taxonomies
|
||||
- [#374](https://github.com/estruyf/vscode-front-matter/issues/374): Hide the front matter section to use the panel instead
|
||||
- [#385](https://github.com/estruyf/vscode-front-matter/issues/385): If no default value for the draft field is defined, the field value will be set to `true`
|
||||
|
||||
### ⚡️ Optimizations
|
||||
|
||||
|
||||
@@ -576,6 +576,7 @@ export class ContentType {
|
||||
|
||||
if (obj.fields) {
|
||||
const dateFormat = Settings.get(SETTING_DATE_FORMAT) as string;
|
||||
|
||||
for (const field of obj.fields) {
|
||||
if (field.name === "title") {
|
||||
if (field.default) {
|
||||
@@ -595,8 +596,16 @@ export class ContentType {
|
||||
if (typeof defaultValue === "string") {
|
||||
data[field.name] = processKnownPlaceholders(defaultValue, titleValue, dateFormat);
|
||||
data[field.name] = await ArticleHelper.processCustomPlaceholders(data[field.name], titleValue, filePath);
|
||||
} else if (typeof defaultValue !== "undefined") {
|
||||
data[field.name] = defaultValue;
|
||||
} else {
|
||||
data[field.name] = typeof defaultValue !== "undefined" ? defaultValue : "";
|
||||
const draftField = ContentType.getDraftField();
|
||||
|
||||
if (field.type === "draft" && (draftField?.type === "boolean" || draftField?.type === undefined)) {
|
||||
data[field.name] = true;
|
||||
} else {
|
||||
data[field.name] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user