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 }))
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 before2..Reproduction
Create a content directory with more than 9 pages
Root cause
@nuxt/content'sgenerateNavigationTreesorts navigation with a plain lexicographic SQL sort onstem: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 }))