From 3a4bb254db42e70770031a5a8ddc4e1be63daf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=B9d=C5=8Dng=20Y=C3=A1ng?= Date: Tue, 23 Jan 2024 09:37:05 +0100 Subject: [PATCH] Be resilient to certain missing fields in metadata.json (#136) --- data/moduleStaticProps.ts | 5 +++-- data/utils.ts | 4 ++-- pages/modules/[module].tsx | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/data/moduleStaticProps.ts b/data/moduleStaticProps.ts index 270311b0d056..b40604ddd68c 100644 --- a/data/moduleStaticProps.ts +++ b/data/moduleStaticProps.ts @@ -27,14 +27,15 @@ export const getStaticPropsModulePage = async ( const metadata = await getModuleMetadata(module) let { versions } = metadata versions = sortVersions(versions) + let yankedVersions = metadata.yanked_versions || {} const versionInfos: VersionInfo[] = await Promise.all( versions.map(async (version) => ({ version, submission: await getSubmissionCommitOfVersion(module, version), moduleInfo: await moduleInfo(module, version), - isYanked: Object.keys(metadata.yanked_versions).includes(version), - yankReason: metadata.yanked_versions[version] || null, + isYanked: Object.keys(yankedVersions).includes(version), + yankReason: yankedVersions[version] || null, })) ) diff --git a/data/utils.ts b/data/utils.ts index 5f1eeeefe43f..809e2c40d952 100644 --- a/data/utils.ts +++ b/data/utils.ts @@ -17,14 +17,14 @@ export const BUILDOZER_BIN = path.join(process.cwd(), 'bin', 'buildozer') export interface Metadata { homepage?: string - maintainers: Array<{ + maintainers?: Array<{ email?: string github?: string name?: string }> repository?: string[] versions: Array - yanked_versions: { + yanked_versions?: { [key: string]: string } } diff --git a/pages/modules/[module].tsx b/pages/modules/[module].tsx index f9c38171a4eb..d514853d9693 100644 --- a/pages/modules/[module].tsx +++ b/pages/modules/[module].tsx @@ -336,7 +336,7 @@ const ModulePage: NextPage = ({

Maintainers

    - {metadata.maintainers.map(({ name, email, github }) => ( + {metadata.maintainers?.map(({ name, email, github }) => (
  • {email && (