Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui committed Nov 3, 2024
1 parent 0e829b3 commit 7233855
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
21 changes: 12 additions & 9 deletions app/packages/[group]/[name]/[version]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metadata> {
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}`,
Expand Down
21 changes: 12 additions & 9 deletions app/packages/[group]/[name]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metadata> {
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}`,
Expand Down
16 changes: 11 additions & 5 deletions app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Metadata> {
const searchParams = await props.searchParams;

if (!searchParams || searchParams.q === "") {
return {
title: "All packages",
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// 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.

0 comments on commit 7233855

Please sign in to comment.