mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 23:44:11 +02:00
refact: use ramda for sorting
This commit is contained in:
+7
-5
@@ -2,6 +2,7 @@ import chain from "ramda/es/chain"
|
||||
import partition from "ramda/es/partition"
|
||||
import pipe from "ramda/es/pipe"
|
||||
|
||||
import { sort } from "ramda"
|
||||
import { IFile, IFileOrFolder, IFolder } from "../types"
|
||||
|
||||
function specificWordsToUpper(str: string): string {
|
||||
@@ -91,16 +92,17 @@ function generateFolder({
|
||||
targets: IFolder[]
|
||||
}): IFolder {
|
||||
const children = join(chain(target => target.children, targets))
|
||||
const sortedChildren = sort((a, b) => {
|
||||
return a.title.split("/").length > b.title.split("/").length
|
||||
? -1
|
||||
: a.title.localeCompare(b.title)
|
||||
}, children)
|
||||
|
||||
return {
|
||||
title,
|
||||
type: "folder",
|
||||
path,
|
||||
children: children.sort((a, b) =>
|
||||
a.title.split("/").length > b.title.split("/").length
|
||||
? -1
|
||||
: a.title.localeCompare(b.title)
|
||||
),
|
||||
children: sortedChildren,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user