sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
863 stars 43 forks source link

Sort, Filter and Group by element in "list" widget #59

Closed Arbee4ever closed 1 year ago

Arbee4ever commented 1 year ago

I have a widget that with multiple values inside, would it be possible to make "sortable_fields" accept something like "list[0].field" to sort by that field?

kyoshino commented 1 year ago

Just checked the code and I think I can fix it quickly. The Netlify/Decap CMS doc actually shows a nested field like language.en but I’ve overlooked such cases. So it’s a bug in Sveltia 🙃

Arbee4ever commented 1 year ago

Oh... but would that also allow accessing array elements with array[index]?

kyoshino commented 1 year ago

Sveltia CMS uses the flat library to “flatten” objects/arrays. For an array, the field name would be something like list.0.field to match the flattened object 🙂

kyoshino commented 1 year ago

The fix is in! 🎉