Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
anakinsleftleg opened this issue Aug 10, 2022 · 3 comments
Labels
enhancement New feature or request Project: v8.1.0

Comments

@anakinsleftleg
Copy link

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
@anakinsleftleg anakinsleftleg added the bug Something isn't working label Aug 10, 2022
@estruyf estruyf added enhancement New feature or request and removed bug Something isn't working labels Aug 11, 2022
estruyf added a commit that referenced this issue Aug 11, 2022
@estruyf
Copy link
Owner

estruyf commented Aug 11, 2022

Thanks, @anakinsleftleg, for this suggestion. The draft field will now be set to true when no default value is provided.

@anakinsleftleg
Copy link
Author

I thought, based on the documentation, that that was already the default outcome.
https://frontmatter.codes/docs/content-creation/fields#outcome

Seems to imply that it is.

@estruyf
Copy link
Owner

estruyf commented Aug 11, 2022

I'll blame the person that wrote the documentation. Oh, wait, that was me. The good thing is that it will now work as how it is documented.

@estruyf estruyf closed this as completed Sep 22, 2022
@estruyf estruyf mentioned this issue Sep 22, 2022
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Project: v8.1.0
Projects
None yet
Development

No branches or pull requests

2 participants