feat: sort movies by rating by default
This commit is contained in:
parent
9c3af5dcc5
commit
a1017b740f
@ -1,4 +1,4 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { getAllMovies, Movie } from "@lib/resource/movies.ts";
|
||||
import { ResourceCard } from "@components/Card.tsx";
|
||||
@ -17,7 +17,10 @@ export const handler: Handlers<
|
||||
const searchParams = parseResourceUrl(req.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, type: "movie" });
|
||||
return ctx.render({ movies, searchResults });
|
||||
return ctx.render({
|
||||
movies: movies.sort((a, b) => a?.meta?.rating > b?.meta?.rating ? -1 : 1),
|
||||
searchResults,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user