hugomods / decap-cms

[Experimental] Hugo Decap CMS Module
https://hugomods.com
MIT License
6 stars 1 forks source link

decap-cms-config.yml loses order of fields array #70

Closed pleasantone closed 9 months ago

pleasantone commented 9 months ago

collection fields is an array, but we're losing order in the array. This makes an unusable editor because the body section isn't output correctly.

See the input file where "title" is first and "body" is last...

config/_default/params.yaml:

decap_cms:
  media_folder: assets/images/uploads
  public_folder: /images/uploads
  display_url: https://example.com/
  search: true
  collections:
    event:
      name: events
      label: Events
      label_singular: Event
      description: Upcoming events
      folder: content/events
      create: true
      media_folder: ''
      public_folder: ''
      slug: "{{year}}-{{slug}}"
      fields:
        - {label: "Title", name: "title", widget: "string"}
        - {label: "Publish Date", name: "publishDate", widget: "datetime"}
        - {label: "Event Date", name: "date", widget: "datetime"}
        - {label: "Expiry Date", name: "expiryDate", widget: "datetime", required: false}
        - {label: "Draft article", name: "draft", widget: "boolean", default: false}
        - {label: "Do not list in index", name: "noindex", widget: "boolean", default: false, required: false}
        - {label: "Feature this article", name: "featured", widget: "boolean", default: false, required: false}
        - {label: "Pinned", name: "pinned", widget: "boolean", default: false, required: false}
        - {label: "Allow comments", name: "comments", widget: "boolean", default: true, required: false}
        - {label: "Intro Blurb", name: "description", widget: "text"}
        - {label: "Authors", name: "authors", widget: "list", default: ["ich", "paul"]}
        - {label: "Area tags", name: "tags", widget: "list", default: ["north-bay", "south-bay", "east-bay", "sierras", "norcal", "socal", "mexico"]}
        - {label: "Featured Images", name: "images", widget: "list", choose_url: false, media_folder: ""}
        - {label: "GPX file", name: "gpxfile", widget: "file", media_folder: "", required: false}
        - {label: "Body", name: "body", widget: "markdown"}

The generated public/decap-cms-config.yaml sorts the fields by name, notice "author" followed by "body" ...

backend:
  branch: main
  name: github
  open_authoring: true
  repo: myorg/example
collections:
- create: true
  description: Upcoming events
  fields:
  - default:
    - ich
    - paul
    label: Authors
    name: authors
    widget: list
  - label: Body
    name: body
    widget: markdown
  - default: true
    label: Allow comments
    name: comments
    required: false
    widget: boolean
  - label: Event Date
    name: date
    widget: datetime
  - label: Intro Blurb
    name: description
    widget: text
  - default: false
    label: Draft article
    name: draft
    widget: boolean
  - label: Expiry Date
    name: expiryDate
    required: false
    widget: datetime
  - default: false
    label: Feature this article
    name: featured
    required: false
    widget: boolean
  - label: GPX file
    media_folder: ""
    name: gpxfile
    required: false
    widget: file
  - choose_url: false
    label: Featured Images
    media_folder: ""
    name: images
    widget: list
  - default: false
    label: Do not list in index
    name: noindex
    required: false
    widget: boolean
  - default: false
    label: Pinned
    name: pinned
    required: false
    widget: boolean
  - label: Publish Date
    name: publishDate
    widget: datetime
  - default:
    - north-bay
    - south-bay
    - east-bay
    - sierras
    - norcal
    - socal
    - mexico
    label: Area tags
    name: tags
    widget: list
  - label: Title
    name: title
    widget: string
  folder: content/events
  label: Events
  label_singular: Event
  media_folder: ""
  name: events
  public_folder: ""
  slug: '{{year}}-{{slug}}'
locale: en
media_folder: assets/images/uploads
public_folder: /images/uploads
publish_mode: editorial_workflow
search: true
site_url: https://goattrails.pst.org/
razonyang commented 9 months ago

Which version of this module do you use? I will check this later.

razonyang commented 9 months ago

Should be fixed since v0.8.1.

image

pleasantone commented 9 months ago

Confirmed, fixed, thanks!