decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.95k stars 3.05k forks source link

List items should not require a `name` #596

Closed julienma closed 5 years ago

julienma commented 7 years ago

- Do you want to request a feature or report a bug? Question, maybe feature.

- What is the current behavior?

The way I define opengraph pictures on my site (using hugo) is to have an images array with values being path to pictures as string, not as an object.

It should be output as this in the front matter:

images:
  - /img/1.jpg
  - /img/2.jpg

So I set up these CMS fields:

      - name: "images"
        label: "OpenGraph Images"
        required: false
        widget: "list"
        fields:
          - {label: "Upload image", widget: "image"}

However it seems name is always output, no matter what I tried:

          - {label: "Upload image", widget: "image"}
// OR
          - {label: "Upload image", widget: "image", name: }
// OR
          - {label: "Upload image", widget: "image", name: ""}

and so this is the current output:

images:
  - 'null': /img/1.jpg
// OR
    undefined: /img/1.jpg

- Question:

Is there any way currently to have multiple list items without any name?

tech4him1 commented 7 years ago

So, just to clarify, you are wanting it to be like this:

images:
  - /img/1.jpg
  - /img/2.jpg
julienma commented 7 years ago

Yes :)

tech4him1 commented 7 years ago

Sorry, I missed that above. I almost wonder if this would be better as a separate Widget type completely. But right now we are setting the name to null or undefined anyway, so maybe it could just be a setting. We would also have to ensure that the list items only had one field if we had it set to an array.

tech4him1 commented 7 years ago

@Benaiah Will #468 work for this as well?

Benaiah commented 7 years ago

@tech4him1 yeah, that will solve this exact usecase and close this issue.

jonas-sk commented 5 years ago

Any updates on this matter? Unfortunately, this is the way Hugo sets Open Graph pictures. I tried taking a look at it but couldn't find a starting point.

erquhart commented 5 years ago

Totally forgot about this - it was never a real issue to begin with, just use field instead of fields to define the image field in your list. It will output a simple list of values rather than objects.

# config
fields:
  - name: images
    widget: list
    field: { name: image, widget: image }

# output
images:
- /img/1.jpg
- /img/2.jpg

Sent with GitHawk