Add store sort options (#238) (#261)

This commit adds the option
to sort store items by name,
and to choose the sort order.

Co-authored-by: udifogiel <udifogiel@proton.me>
This commit is contained in:
laylafogiel-hash
2025-10-13 03:20:48 +03:00
committed by GitHub
parent f5cb856d3d
commit 97c6f3490c
2 changed files with 33 additions and 7 deletions

View File

@ -18,7 +18,8 @@ const StoreRead = type({
company: "string?",
companyActions: "string = 'published,developed'",
sort: "'default' | 'newest' | 'recent' = 'default'",
sort: "'default' | 'newest' | 'recent' | 'name' = 'default'",
order: "'asc' | 'desc' = 'desc'",
});
export default defineEventHandler(async (h3) => {
@ -101,10 +102,13 @@ export default defineEventHandler(async (h3) => {
switch (options.sort) {
case "default":
case "newest":
sort.mReleased = "desc";
sort.mReleased = options.order;
break;
case "recent":
sort.created = "desc";
sort.created = options.order;
break;
case "name":
sort.mName = options.order;
break;
}
@ -119,4 +123,4 @@ export default defineEventHandler(async (h3) => {
]);
return { results, count };
});
});