Skip to content

Default and hidden variables don't reflect in mdx file #4520

@lilpolymath

Description

@lilpolymath

Describe the bug

I have this collection of files and here is the config.yml specification

  - name: support-page
    label: Support Pages
    extension: mdx
    format: frontmatter
    editor:
      preview: true
    delete: false
    files:
      - file: 'content/support/support.mdx'
        label: Support
        name: support
        fields:
          - label: Template
            name: template
            widget: hidden
            default: Support
          - label: Slug
          - label: Slug
            name: slug
            widget: hidden
            default: support
          - label: Title
            name: title
            widget: string
          - label: accordion
            name: accordion
            widget: list
            fields:
              - label: title
                name: title
                widget: string
                default: ''
              - label: content
                name: content
                widget: list
                fields:
                  - default: ''
                    label: title
                    name: title
                    widget: string
                  - label: description
                    name: description
                    widget: string

But whenever I update the file this is what gets created.

---
title: Frequently Asked Questions
accordion:
  - title: General
    content:
      - title: Can you finish our project in less than a day?
        description: No.
---

Here is the template declaration in the cms.js

CMS.registerPreviewTemplate('support', ({ entry }) => (
  <SupportTemplate {...entry.toJS().data} />
))

The default && hidden variables I declared in the config don't show up in the file at all and it prevents the page from getting created.

Expected behaviour
I expect that the file has this content

---
template: Support
slug: support
title: Frequently Asked Questions
accordion:
  - title: General
    content:
      - title: Can you finish our project in less than a day?
        description: No.
---

Screenshots

Applicable Versions:

  • Netlify CMS version: netlify-cms-app 2.13.1
  • Git provider: GitHub
  • OS: Elementary OS
  • Browser version: Chrome 86

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions