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

Support for yaml lists #12

Closed
Jawabiscuit opened this issue Feb 23, 2024 · 3 comments
Closed

Support for yaml lists #12

Jawabiscuit opened this issue Feb 23, 2024 · 3 comments

Comments

@Jawabiscuit
Copy link

Jawabiscuit commented Feb 23, 2024

How would I configure this frontmatter in pages? It seems like there needs
to be an array object in the schema besides select. There isn't anything in the configuration help for yaml lists unless I'm missing something.

resources:
  - name: featured-image
    src: featured-image.jpg

I tried...

content:
  - name: posts
    label: Posts
    type: collection
    path: content/posts
    fields:
      - {name: draft, label: Draft, type: boolean, default: true}
      - {name: title, label: Title, type: string}
      - {name: date, label: Date, type: date}
      - name: resources
        label: Resources
        type: object
        fields:
          - name: name
            type: string
            hidden: true
            default: featured-image
          - name: src
            label: Featured Image
            type: image
    filename: index.md
    view:
      fields: [title, draft, date]

...which outputs something like...

resources:
  name: featured-image
  src: featured-image.jpg

... when I select an image in the UI an save.

I also tried...

content:
  - name: posts
    label: Posts
    type: collection
    path: content/posts
    fields:
      - {name: draft, label: Draft, type: boolean, default: true}
      - {name: title, label: Title, type: string}
      - {name: date, label: Date, type: date}
      - name: resources
        label: Resources
        type: object
        fields:
          - name: featured-image
            label: Featured Image
            type: object
            fields:
            - name: name
              type: string
              hidden: true
              default: featured-image
            - name: src
              label: Featured Image
              type: image
    filename: index.md
    view:
      fields: [title, draft, date]

...which outputs something like...

resources:
  featured-image:
      name: featured-image
      src: featured-image.jpg

This would better support resources metadata in Hugo. I highly suggest reading the spec to get a better sense of the capabilities beyond specifying one metadata entry. In this simple use-case, Hugo uses this frontmatter to insert the feature image into the post. If there is an additional feature-image-preview entry, then that will be displayed on the posts page as a small preview image above the link to the post.

I also use page bundles with Hugo, which is why filenames of my posts are index.md, similar to #10 which works fine (but there is no limit to how many entries you can make which is what the issue is about). The parent directory of index.md I like to name {year}-{month}-{day}-{primary} for example, but could be named anything.

Thanks for the great tool!

@Jawabiscuit
Copy link
Author

Jawabiscuit commented Feb 24, 2024

Nevermind, I figured it out:

content:
  - name: posts
    label: Posts
    type: collection
    path: content/posts
    fields:
      - {name: draft, label: Draft, type: boolean, default: true}
      - {name: title, label: Title, type: string}
      - {name: date, label: Date, type: date}
      - name: resources
        label: Resources
        type: object
---->   list: true
        fields:
          - name: name
            type: string
            hidden: true
            default: featured-image
          - name: src
            label: Featured Image
            type: image
    filename: index.md
    view:
      fields: [title, draft, date]

@hunvreus
Copy link
Member

Sorry, I was slow to respond. Glad you got that sorted out.

@Jawabiscuit
Copy link
Author

No problem, I figured there had to be some way I just wasn't seeing it and I imagine you're swamped. Now, if could figure out how to get pages to output

resources:
  - name: featured-image
    src: featured-image.jpg

instead of

resources:
  - name: featured-image
    src: /content/posts/2024-02-24-green-eggs/featured-image.jpg

I'd really be in business! With various ways of configuring media and images, it's not super clear how their setting all interact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants