Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { cloneDeep } from 'es-toolkit/object';
import { type NextPageContext } from 'next';

import HomeScene from '~/scenes/HomeScene';
Expand All @@ -7,7 +8,7 @@ import getApiUrl from '~/util/getApiUrl';
import urlWithQuery from '~/util/urlWithQuery';

function Index(props: HomePageProps) {
return <HomeScene {...props} />;
return <HomeScene {...cloneDeep(props)} />;
}

const LIMIT = 8;
Expand Down Expand Up @@ -56,7 +57,7 @@ Index.getInitialProps = async (ctx: NextPageContext) => {
);

const statisticResponse = await fetch(
getApiUrl(urlWithQuery('/libraries/statistic', {}), ctx),
getApiUrl(urlWithQuery('/libraries/statistic'), ctx),
NEXT_1H_CACHE_HEADER
);

Expand Down
4 changes: 2 additions & 2 deletions scenes/TrendingScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function TrendingScene({ data, query }: TrendingPageProps) {
const total = data && data.total;

function handleClearAllPress() {
void router.replace(urlWithQuery('/trending', {}));
void router.replace(urlWithQuery('/trending'));
}

return (
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function TrendingScene({ data, query }: TrendingPageProps) {
<P style={tw`p-6 text-sm text-secondary`}>
Unfortunately that&apos;s all, what&apos;s trending now. Want to explore more libraries?
Check out the{' '}
<A href={urlWithQuery('/packages', {})} target="_self">
<A href={urlWithQuery('/packages')} target="_self">
directory home page
</A>
.
Expand Down
2 changes: 1 addition & 1 deletion util/urlWithQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function toQueryString(query: Query) {
return new URLSearchParams(query as Record<string, string>).toString();
}

export default function urlWithQuery(url: string, query: Partial<Query>): string {
export default function urlWithQuery(url: string, query: Partial<Query> = {}): string {
const queryString = toQueryString(
Object.fromEntries(Object.entries(query).filter(([, v]) => Boolean(v)))
);
Expand Down