Skip to content

Commit

Permalink
web: fix file sorting and add stat
Browse files Browse the repository at this point in the history
  • Loading branch information
mnerv committed Dec 22, 2024
1 parent 20bdd95 commit df6a1ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions web/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<FileTree {tree} />
{/each}
</div>
<div class="py-4 px-3 dark:text-gray-400 text-gray-500 flex space-x-2 my-auto">
<Icon icon="bi:filetype-pdf" class="my-auto text-base"/>
<p class="text-sm my-auto">
{registry.length}
</p>
</div>
<div class='fixed bottom-0 right-0 p-4 hover:text-blue-nordic'>
<a class='mx-auto hover:underline hover:text-blue-400 transition-all duration-150 font-light'
href='https://github.com/mnerv/notes'
Expand Down
8 changes: 7 additions & 1 deletion web/src/FileTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ export type NodeT = {
}

export function sortByType(list: NodeT[]): NodeT[] {
if (list === null || list.length == 0) return []
const directory = list.filter(a => a.href === '')
const files = list.filter(a => a.href !== '')
return [...directory, ...files]
const sortedList = [...directory, ...files]
// sort childrens
return sortedList.map(n => {
n.children = sortByType(n.children)
return n
})
}

export function sortByName(list: NodeT[]): NodeT[] {
Expand Down

0 comments on commit df6a1ea

Please sign in to comment.