fix: need to parse search query from request

This commit is contained in:
Derrick Hammer 2023-12-22 03:28:16 -05:00
parent 2bd0cf429c
commit 0aadf6f6f7
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 3 deletions

View File

@ -3,11 +3,14 @@ import { fetchFeedData } from "@/lib/feed";
type Filter = "latest" | "day" | "week" | "month";
export async function loader({ params }: LoaderFunctionArgs) {
export async function loader({ request }: LoaderFunctionArgs) {
const search = new URL(request.url).searchParams;
let filter: Filter | null = null;
let page = "0";
if (params?.searchParams) {
({ filter, page = "0" } = params.searchParams as any as {
const searchEntries = Array.from(search.entries());
if (searchEntries.length) {
const searchParams = Object.fromEntries(searchEntries);
({ filter, page = "0" } = searchParams as any as {
filter: Filter;
page: string;
});