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

List items should not require a name #596

Closed
julienma opened this issue Sep 12, 2017 · 7 comments
Closed

List items should not require a name #596

julienma opened this issue Sep 12, 2017 · 7 comments

Comments

@julienma
Copy link

- 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
Copy link
Contributor

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

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

@julienma
Copy link
Author

Yes :)

@tech4him1
Copy link
Contributor

tech4him1 commented Sep 12, 2017

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
Copy link
Contributor

@Benaiah Will #468 work for this as well?

@Benaiah
Copy link
Contributor

Benaiah commented Sep 12, 2017

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

@jonas-sk
Copy link

jonas-sk commented Jun 7, 2019

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.

jonas-sk added a commit to jonas-sk/pine-maastricht that referenced this issue Jun 7, 2019
@erquhart
Copy link
Contributor

erquhart commented Jun 7, 2019

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

@erquhart erquhart closed this as completed Jun 7, 2019
jonas-sk added a commit to jonas-sk/pine-maastricht that referenced this issue Jun 7, 2019
jonas-sk added a commit to jonas-sk/pine-maastricht that referenced this issue Jun 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants