From 9b21e15c631f7366f7f1082dd956b69f55cb056b Mon Sep 17 00:00:00 2001 From: Elio Struyf Date: Fri, 9 Sep 2022 16:44:37 +0200 Subject: [PATCH] #402: Custom sorting of content now supports `number` fields --- CHANGELOG.md | 1 + package.json | 3 ++- src/dashboardWebView/hooks/usePages.tsx | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 973afc7c..76e986b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - [#388](https://github.com/estruyf/vscode-front-matter/issues/388): New stop server action has been added to the panel - [#390](https://github.com/estruyf/vscode-front-matter/issues/390): Implement another JSON parser in order to be able to parse the `frontmatter.json` file better - [#394](https://github.com/estruyf/vscode-front-matter/issues/394): Ordering of snippet fields is based on their field definition +- [#402](https://github.com/estruyf/vscode-front-matter/issues/402): Custom sorting of content now supports `number` fields ### ⚡️ Optimizations diff --git a/package.json b/package.json index 18c23b45..a711e7ca 100644 --- a/package.json +++ b/package.json @@ -329,7 +329,8 @@ "default": "string", "enum": [ "string", - "date" + "date", + "number" ], "description": "Type of the field value" } diff --git a/src/dashboardWebView/hooks/usePages.tsx b/src/dashboardWebView/hooks/usePages.tsx index d8fec691..f54a685d 100644 --- a/src/dashboardWebView/hooks/usePages.tsx +++ b/src/dashboardWebView/hooks/usePages.tsx @@ -67,6 +67,8 @@ export default function usePages(pages: Page[]) { pagesSorted = pagesSorted.sort(Sorting.alphabetically(name)); } else if (type === SortType.date) { pagesSorted = pagesSorted.sort(Sorting.date(name)); + } else if (type === SortType.number) { + pagesSorted = pagesSorted.sort(Sorting.number(name)); } if (order === SortOrder.desc) {