mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 22:02:46 -07:00
refactor(packages/*): add tuono- prefix to all relevant folders (#255)
This commit is contained in:
committed by
GitHub
parent
f236b75f55
commit
f3bf13da59
@@ -0,0 +1,17 @@
|
||||
import type { RouteNode } from './types'
|
||||
import { multiSortBy } from './utils'
|
||||
import { ROOT_PATH_ID } from './constants'
|
||||
|
||||
// Routes need to be sorted in order to iterate over the handleNode fn
|
||||
// with first the items that might be parent routes
|
||||
export const sortRouteNodes = (routes: Array<RouteNode>): Array<RouteNode> =>
|
||||
multiSortBy(routes, [
|
||||
(d): number => (d.routePath === '/' ? -1 : 1),
|
||||
(d): number => d.routePath.split('/').length,
|
||||
// Dynamic route
|
||||
(d): number => (d.routePath.endsWith(']') ? 1 : -1),
|
||||
(d): number => (d.filePath.match(/[./]index[.]/) ? 1 : -1),
|
||||
(d): number => (d.filePath.match(/[./]route[.]/) ? -1 : 1),
|
||||
(d): number => (d.routePath.endsWith('/') ? -1 : 1),
|
||||
(d): string => d.routePath,
|
||||
]).filter((d) => ![`/${ROOT_PATH_ID}`].includes(d.routePath || ''))
|
||||
Reference in New Issue
Block a user