Skip to content

Sidebar navigation orders pages lexicographically, so 10. sorts before 2. #1412

Description

@blombard

Describe the bug

Content pages are ordered using numeric filename prefixes (1., 2., 3., …).
This ordering is not a natural numeric order — it's a lexicographic (alphabetical)
string sort. As soon as a directory contains a two-digit prefix, the order breaks:
10. sorts before 2..

Reproduction

Create a content directory with more than 9 pages

Root cause

@nuxt/content's generateNavigationTree sorts navigation with a plain lexicographic SQL sort on stem:

queryBuilder = queryBuilder.order("stem", "ASC");

Since stem retains the numeric file prefixes (e.g. en/4.ai/10.foo), the string comparison places 10. before 2..

AI Proposed fix

Re-sort the navigation tree in transformNavigation (stemA.localeCompare(stemB, undefined, { numeric: true }))

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