Skip to content

Commit

Permalink
feat: fansub follow search
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed May 8, 2023
1 parent 29d8c54 commit ec3ed74
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/app/src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ const search = Astro.url.searchParams;
const runtime = getRuntime<Env>(Astro.request);
const timestamp = new Date((await runtime?.env.animegarden.get('state/refresh-timestamp')) ?? 0);
function followSearch(params: Record<string, string>) {
const s = new URLSearchParams(search);
for (const [key, value] of Object.entries(params)) {
s.set(key, value)
}
return s.toString();
}
---

<!DOCTYPE html>
Expand Down Expand Up @@ -57,7 +65,7 @@ const timestamp = new Date((await runtime?.env.animegarden.get('state/refresh-ti
{
types.map((t) => (
<a
href={`/resources/1?type=${t}`}
href={`/resources/1?${followSearch({ type: t })}`}
class="px2 py1 block text-base-600 text-link-active"
>
{t}
Expand All @@ -78,7 +86,7 @@ const timestamp = new Date((await runtime?.env.animegarden.get('state/refresh-ti
{
fansubs.map((t) => (
<a
href={`/resources/1?fansub=${t.id}`}
href={`/resources/1?${followSearch({ fansub: '' + t.id })}`}
class="px2 py1 block text-base-600 text-link-active"
>
{t.name}
Expand Down

0 comments on commit ec3ed74

Please sign in to comment.