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

Changing the default sort on Admin UI page #304

Closed
alexpetralia opened this issue Jan 14, 2025 · 8 comments
Closed

Changing the default sort on Admin UI page #304

alexpetralia opened this issue Jan 14, 2025 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@alexpetralia
Copy link

Hello, thank you for all your work here! Setup was very simple thanks to your docs.

I just had one quick question: in the Admin UI page, is it possible to set a default sort field?

I see in the Decamp CMS config that we can specify fields which are sortable, but not necessarily one for which to be the default sort (e.g. last_modified DESC).

@kyoshino
Copy link
Member

Hiya! Actually, Static CMS, a now-discontinued Netlify CMS fork, has altered the sortable_fields option to include the default sort field and direction. I’m thinking about adding compatibility for it. Will work on it shortly.

This is the relevant Netlify/Decap CMS issue:

@kyoshino kyoshino self-assigned this Jan 14, 2025
@kyoshino kyoshino added the enhancement New feature or request label Jan 14, 2025
@kyoshino
Copy link
Member

The extended sortable_fields option is shipped with v0.54.0.

@alexpetralia
Copy link
Author

Amazing, thank you so much!! This is awesome.

@alexpetralia
Copy link
Author

alexpetralia commented Jan 25, 2025

Hi @kyoshino I attempted to apply this code change to my config.yml but don't seem to be getting the intended results.

Here is the relevant section of my admin/config.yml:

collections:
  - name: 'Posts'
    label: 'Posts'
    label_singular: 'Post'
    folder: '_posts/'
    create: true
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    summary: '{{date}} - {{title}} [{{tags}}]'
    editor:
      preview: true
    display_fields: [title, date]
    sortable_fields: 
      fields: [title, date]
      default:
        field: date
        direction: descending

I can see that in my _posts frontmatter I use the field date. However, when I open up the Admin page (http://localhost:4000/admin/index.html#/collections/Posts), the posts are still not sorting by date: descending. I need to click "Publish Date, new to old" in order to correct it.

Image

I can see I am on the newest release: https://unpkg.com/@sveltia/cms@0.55.0/dist/sveltia-cms.js. I also tried using published_date (as well as title even) instead of date but that did not work either.

Do you see anything at first glance I'm doing incorrectly here?

Thanks,
Alex

@kyoshino
Copy link
Member

Sorry I was offline. Will check this again tomorrow.

@kyoshino kyoshino reopened this Jan 29, 2025
@josineto
Copy link

I have the same problem, but noticed one more detail: the bug (if it is a bug) only affects the first collection. I have four collections, and have configured them with default sorting. The first collection doesn't get any default sorting, but the other three are working. @kyoshino

@kyoshino
Copy link
Member

The remaining issue fixed with v0.56.0.

@alexpetralia
Copy link
Author

It is working for me now, thanks again!

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

No branches or pull requests

3 participants