diff --git a/app/packages/[group]/[name]/[version]/page.tsx b/app/packages/[group]/[name]/[version]/page.tsx index 30221c88..cb03e88f 100644 --- a/app/packages/[group]/[name]/[version]/page.tsx +++ b/app/packages/[group]/[name]/[version]/page.tsx @@ -5,27 +5,30 @@ import { Pack } from "../_components/pack"; export const revalidate = 86400; // 1 day -type Params = { +type Params = Promise<{ group: string; name: string; version: string; -}; - -type Props = { - params: Params; - searchParams: { [key: string]: string | string[] | undefined }; -}; +}>; +type SearchParams = Promise<{ [key: string]: string | string[] | undefined }>; export async function generateMetadata( - { params, searchParams }: Props, + props: { + params: Params; + }, parent: ResolvingMetadata, ): Promise { + const params = await props.params; return { title: `${params.group}/${params.name} (v${params.version})`, }; } -export default async function Version({ params }: { params: Params }) { +export default async function Page(props: { + params: Params; +}) { + const params = await props.params; + const hasuraClient = getHasuraClient(); const data = await hasuraClient.getPackageByNameAndVersion({ name: `${params.group}/${params.name}`, diff --git a/app/packages/[group]/[name]/page.tsx b/app/packages/[group]/[name]/page.tsx index 37c71798..f6df49cf 100644 --- a/app/packages/[group]/[name]/page.tsx +++ b/app/packages/[group]/[name]/page.tsx @@ -5,26 +5,29 @@ import { Pack } from "./_components/pack"; export const revalidate = 86400; // 1 day -type Params = { +type Params = Promise<{ group: string; name: string; -}; - -type Props = { - params: Params; - searchParams: { [key: string]: string | string[] | undefined }; -}; +}>; +type SearchParams = Promise<{ [key: string]: string | string[] | undefined }>; export async function generateMetadata( - { params, searchParams }: Props, + props: { + params: Params; + }, parent: ResolvingMetadata, ): Promise { + const params = await props.params; return { title: `${params.group}/${params.name} (latest)`, }; } -export default async function Name({ params }: { params: Params }) { +export default async function Page(props: { + params: Params; +}) { + const params = await props.params; + const hasuraClient = getHasuraClient(); const data = await hasuraClient.getPackagesByName({ name: `${params.group}/${params.name}`, diff --git a/app/search/page.tsx b/app/search/page.tsx index fbffde54..1ee02763 100644 --- a/app/search/page.tsx +++ b/app/search/page.tsx @@ -8,14 +8,16 @@ import { Pagination } from "./_components/pagination"; export const revalidate = 86400; // 1 day -type Props = { - searchParams: { [key: string]: string | string[] | undefined }; -}; +type SearchParams = Promise<{ [key: string]: string | string[] | undefined }>; export async function generateMetadata( - { searchParams }: Props, + props: { + searchParams: SearchParams; + }, parent: ResolvingMetadata, ): Promise { + const searchParams = await props.searchParams; + if (!searchParams || searchParams.q === "") { return { title: "All packages", @@ -27,7 +29,11 @@ export async function generateMetadata( }; } -export default async function Search({ searchParams }: Props) { +export default async function Page(props: { + searchParams: SearchParams; +}) { + const searchParams = await props.searchParams; + const query = String(searchParams?.q) ?? ""; const page = Number(searchParams?.page ?? 1); const perPage = Number(searchParams?.perPage ?? PER_PAGE); diff --git a/next-env.d.ts b/next-env.d.ts index fd36f949..725dd6f2 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -3,4 +3,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. +// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.