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

Manage a collection in a single file #60

Closed
tforster opened this issue Apr 25, 2024 · 4 comments
Closed

Manage a collection in a single file #60

tforster opened this issue Apr 25, 2024 · 4 comments

Comments

@tforster
Copy link

Is it possible to manage a single collection, aka multiple pages or posts, in a single json or yaml file?

@hunvreus
Copy link
Member

You could define a single file as JSON, TOML or YAML (even CSV if you use the datagrid type). I do that sometimes to manage things like a list of authors for a blog:

- name: authors
    label: Authors
    type: file
    path: _data/authors.json
    list: true
    fields:
      - name: name
        label: Name
        type: string
      - name: age
        label: Age
        type: number
      - name: featured
        label: Featured
        type: boolean
      - name: email
        label: Email
        type: string
        pattern: ^(|[\w\.-]+@[\w\.-]+\.\w+)$
      - name: avatar
        label: Avatar
        type: image
        options:
          path: images/avatars

This effectively allows you to save your list of authors (each with name, age, featured, email and avatar fields) as a JSON array.

@hunvreus
Copy link
Member

hunvreus commented May 2, 2024

Did that work for you @tforster ?

@tforster
Copy link
Author

tforster commented May 3, 2024

@hunvreus Sorry, I was pulled into another project. I am going to give it a try but I suspect the number of fields I have in my schema will make the UI uncomfortable.

It's not a huge deal as I am streaming the json files and can merge them into the one data structure that I need.

@tforster
Copy link
Author

tforster commented May 3, 2024

We can close this issue as the response was suitable.

@hunvreus hunvreus closed this as completed May 5, 2024
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