Skip to content

Commit

Permalink
feat: filter by before and after
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed May 3, 2023
1 parent 32caf9c commit 7b006c7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/app/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export async function fetchResources(
fansub?: number;
publisher?: number;
type?: string;
after?: Date;
before?: Date;
} = {}
) {
return (
Expand All @@ -43,7 +45,9 @@ export async function fetchResources(
: undefined,
fansub: options.fansub ? '' + options.fansub : undefined,
publisher: options.publisher ? '' + options.publisher : undefined,
type: options.type ? '' + options.type : undefined
type: options.type ? '' + options.type : undefined,
after: options.after,
before: options.before
})
).resources;
}
Expand Down
9 changes: 8 additions & 1 deletion packages/app/src/pages/resources/[page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ const fansub = url.searchParams.get('fansub');
const _type = url.searchParams.get('type');
const type = _type && _type in QueryType ? QueryType[_type] : _type;
const _after = url.searchParams.get('after');
const after = _after ? new Date(_after) : undefined;
const _before = url.searchParams.get('before');
const before = _before ? new Date(_before) : undefined;
const _include = url.searchParams.get('include');
const include = _include ? JSON.parse(_include) : undefined;
const _exclude = url.searchParams.get('exclude');
Expand All @@ -25,7 +30,9 @@ const resources = await fetchResources(page, {
fansub: fansub ? +fansub : undefined,
type: type ? type : undefined,
include,
exclude
exclude,
after,
before
});
---

Expand Down

0 comments on commit 7b006c7

Please sign in to comment.