Skip to content

Commit 78dc97d

Browse files
committed
fix(pages ongs): adjusted generate static params
1 parent 668de29 commit 78dc97d

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

  • src/app/(user-scope)/ongs/[slug]

src/app/(user-scope)/ongs/[slug]/page.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ export const generateMetadata = async ({
4141
export async function generateStaticParams() {
4242
const { data } = await instanceMotor.organizations.getAllOrganizations()
4343

44-
const filteredOngs = data?.organizations?.filter(
45-
org => org?.organization_profile?.slug !== null
44+
return (
45+
data?.organizations
46+
?.filter(
47+
(
48+
org
49+
): org is PostgresOrganization & {
50+
organization_profile: { slug: string }
51+
} =>
52+
typeof org?.organization_profile?.slug === 'string' &&
53+
org.organization_profile.slug.trim().length > 0
54+
)
55+
.map(org => ({
56+
slug: org.organization_profile.slug
57+
})) ?? []
4658
)
47-
48-
return filteredOngs.map((org: PostgresOrganization) => ({
49-
slug: org?.organization_profile?.slug
50-
}))
5159
}
5260

5361
const Page: NextPage<OngPageProps> = async ({ params }) => {

0 commit comments

Comments
 (0)