Skip to content

Issue: Draft field in custom content type does not default to value of true #385

@anakinsleftleg

Description

@anakinsleftleg

Describe the bug
When creating a new content with custom content type, draft field is populated as draft: "" unless content type has a default value of true set for the draft field.

To Reproduce
Steps to reproduce the behavior:
Here is my frontmatter.json

{
  "$schema": "https://frontmatter.codes/frontmatter.schema.json",
  "frontMatter.taxonomy.contentTypes": [
    {
      "name": "blog",
      "pageBundle": true,
      "template": "[[workspace]]/archetypes/blog/index.md",
      "previewPath": null,
      "fields": [
        {
          "title": "Title",
          "name": "title",
          "type": "string",
          "single": true,
          "default": "{{title}}"
        },
        {
          "title": "Slug",
          "name": "slug",
          "type": "slug",
          "editable": true,
          "default": "{{slug}}"
        },
        {
          "title": "Is in draft",
          "name": "draft",
          "type": "draft"
        },
        {
          "title": "Creation date",
          "name": "date",
          "type": "datetime",
          "isPublishDate": true,
          "default": "{{now}}"
        },
        {
          "title": "Modified date",
          "name": "lastmod",
          "type": "datetime",
          "isModifiedDate": true,
          "default": "{{now}}"
        },
        {
          "title": "Description",
          "name": "description",
          "type": "string",
          "default": "&summary"
        },
        {
          "title": "Summary",
          "name": "summary",
          "type": "string",
          "default": "*summary"
        },
        {
          "title": "Keywords",
          "name": "keywords",
          "type": "list",
          "default": ""
        },
        {
          "title": "Content type",
          "name": "type",
          "type": "string",
          "default": "blog"
        },
        {
          "title": "Weight",
          "name": "weight",
          "type": "number",
          "default": 10
        },
        {
          "title": "Sub-title",
          "name": "subtitle",
          "type": "string",
          "single": false,
          "wysiwyg": true,
          "default": ""
        },
        {
          "title": "Is a Featured Post",
          "name": "featuredPost",
          "type": "boolean",
          "default": false
        },
        {
          "title": "Header Image",
          "name": "headerImage",
          "type": "fields",
          "fields": [
            {
              "title": "Image",
              "name": "src",
              "type": "image",
              "default": "images/headerdefault.png",
              "isPreviewImage": true
            },
            {
              "title": "Image title",
              "name": "title",
              "type": "string",
              "single": true,
              "default": ""
            },
            {
              "title": "Image Alt-Text",
              "name": "alt",
              "type": "string",
              "single": true,
              "default": ""
            }
          ]
        },
        {
          "title": "Categories",
          "name": "categories",
          "type": "categories"
        },
        {
          "title": "Tags",
          "name": "tags",
          "type": "tags"
        }
      ]
    }
  ],
  "frontMatter.framework.id": "hugo",
  "frontMatter.content.publicFolder": "assets",
  "frontMatter.content.pageFolders": [
    {
      "title": "Pages",
      "path": "[[workspace]]/content",
      "excludeSubdir": true
    },
    {
      "title": "Blog",
      "path": "[[workspace]]/content/blog"
    },
    {
      "title": "About Page",
      "path": "[[workspace]]/content/about"
    }
  ],
  "frontMatter.dashboard.content.cardTags": "tags"
}

When draft is:

        {
          "title": "Is in draft",
          "name": "draft",
          "type": "draft"
        },

The frontmatter becomes:

draft: ""

I have to explicitly state:

        {
          "title": "Is in draft",
          "name": "draft",
          "type": "draft",
          "default": true
        },

in order to get:

draft: true

Expected behavior
Standard draft field should have default of true value on frontmatter creation.

Desktop (please complete the following information):

  • OS: Windows 10
  • VScode 1.7.0
  • Front Matter 8.0.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions