Skip to content

feat(admin): add sort_order column on _emdash_collections to override alphabetical sidebar order #795

Closed as not planned

Description

@othersh0re

Problem

CollectionRepository.list() (in registry-Ci3WxVAr.mjs:361) hardcodes .orderBy("slug", "asc") when fetching collections. This propagates to the manifest and into the admin sidebar, so editors see collections sorted alphabetically by slug — which usually doesn't match how often a collection is edited or where it sits in editorial priority.

We just rolled out a deployment with 9 collections (pages, posts, case_studies, resources, solutions, team_members, webinars, plus two custom ones — legal and landing_pages). The marketing team's mental priority order is:

  1. Pages (most-edited)
  2. Solutions
  3. Case Studies
  4. Resources
  5. Landing Pages
  6. Blog Posts
  7. Webinars
  8. Team Members
  9. Legal (least-edited reference content)

But the sidebar shows them as: Case Studies, Landing Pages, Legal, Pages, Posts, Resources, Solutions, Team Members, Webinars. "Legal" floats to position 3 because it starts with "L", which is the opposite of what we want.

There's currently no way to override this without renaming slugs to prefix-encode the order (01_pages, 02_solutions, …) — which breaks every getEmDashEntry() call site and ripples through generated types.

Proposal

Add a nullable sort_order INTEGER column to _emdash_collections, mirroring the same field that already exists on _emdash_fields:

.orderBy("sort_order", "asc")
.orderBy("slug", "asc")  // tiebreaker

Behaviour:

  • sort_order = NULL → fall back to alphabetical (preserves current behaviour for existing deployments)
  • sort_order = <integer> → places the collection at that position
  • Seed file gains an optional sortOrder field on each collection block, mirroring fields[].sortOrder
  • Admin UI: when this lands, an obvious follow-up is a drag-to-reorder affordance in /admin/settings/content-types, but the field on its own is enough to unblock people via seed/CLI

Why not just rename slugs

Tried it; bad path. The slug is used:

  • As the foreign key in _emdash_fields.collection_id-shaped joins
  • As the URL discriminator in [collection]/[id] admin routes
  • As the API key in getEmDashEntry(collection, slug) call sites in user code
  • As the type key in generated emdash-env.d.ts

A prefix rename touches everything. A sort_order column touches nothing user-visible except the sidebar order.

Prior art

The _emdash_fields table already has sort_order INTEGER and CollectionRepository.listFields() already uses .orderBy("sort_order", "asc").orderBy("created_at", "asc"). This proposal extends the same pattern up one level.

Happy to PR this

Small, self-contained change. Migration adds the column, the seeder writes it, the repository method picks it up. If you'd rather have it land that way let me know — otherwise an upvote thumb on this issue is fine and we'll wait for whoever lands it.

Activity

  1. ascorbic commented on Apr 29, 2026

    @ascorbic
    Member

    Closing as a duplicate of #474, which tracks the same request (collection sort order in admin sidebar). #474 has earlier discussion -- please follow that one for updates and feel free to add any details from your spec proposal there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions