Skip to content

Commit df6a1ea

Browse files
committed
web: fix file sorting and add stat
1 parent 20bdd95 commit df6a1ea

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

web/src/App.svelte

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
<FileTree {tree} />
3838
{/each}
3939
</div>
40+
<div class="py-4 px-3 dark:text-gray-400 text-gray-500 flex space-x-2 my-auto">
41+
<Icon icon="bi:filetype-pdf" class="my-auto text-base"/>
42+
<p class="text-sm my-auto">
43+
{registry.length}
44+
</p>
45+
</div>
4046
<div class='fixed bottom-0 right-0 p-4 hover:text-blue-nordic'>
4147
<a class='mx-auto hover:underline hover:text-blue-400 transition-all duration-150 font-light'
4248
href='https://github.com/mnerv/notes'

web/src/FileTree.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ export type NodeT = {
88
}
99

1010
export function sortByType(list: NodeT[]): NodeT[] {
11+
if (list === null || list.length == 0) return []
1112
const directory = list.filter(a => a.href === '')
1213
const files = list.filter(a => a.href !== '')
13-
return [...directory, ...files]
14+
const sortedList = [...directory, ...files]
15+
// sort childrens
16+
return sortedList.map(n => {
17+
n.children = sortByType(n.children)
18+
return n
19+
})
1420
}
1521

1622
export function sortByName(list: NodeT[]): NodeT[] {

0 commit comments

Comments
 (0)