From 00caa70143d73aa24d3a1577887edf1e8d178c9d Mon Sep 17 00:00:00 2001 From: Rebecca-Chou Date: Thu, 10 Mar 2022 10:31:57 +0800 Subject: [PATCH] fix data type --- lib/team.ts | 14 +++++--------- pages/about/team.tsx | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/team.ts b/lib/team.ts index a82a5b55..2c4447ef 100644 --- a/lib/team.ts +++ b/lib/team.ts @@ -88,13 +88,11 @@ export async function getExecNamePosPairs() { return formattedExec; } -export async function getExec(execNamePosPair: string[], convert = true) { +export async function getExec(name: string, pos: string, convert = true) { let content, metadata; try { - const raw = await readFile( - path.join(EXECS_PATH, `${execNamePosPair[0]}${fileType}`) - ); + const raw = await readFile(path.join(EXECS_PATH, `${name}${fileType}`)); ({ content, data: metadata } = matter(raw)); const image = @@ -107,13 +105,11 @@ export async function getExec(execNamePosPair: string[], convert = true) { }; } catch (err) { const firstName = - execNamePosPair[0].split("-")[0][0].toUpperCase() + - execNamePosPair[0].split("-")[0].slice(1); + name.split("-")[0][0].toUpperCase() + name.split("-")[0].slice(1); const lastName = - execNamePosPair[0].split("-")[1][0].toUpperCase() + - execNamePosPair[0].split("-")[1].slice(1); + name.split("-")[1][0].toUpperCase() + name.split("-")[1].slice(1); - const posName = execPositions[execNamePosPair[1]]; + const posName = execPositions[pos]; ({ content, metadata } = { content: "Coming soon!", metadata: { diff --git a/pages/about/team.tsx b/pages/about/team.tsx index d236fa60..05a1ee74 100644 --- a/pages/about/team.tsx +++ b/pages/about/team.tsx @@ -211,7 +211,7 @@ export const getStaticProps: GetStaticProps = async () => { const execNamePosPairs = await getExecNamePosPairs(); const execs = (await Promise.all( - execNamePosPairs.map((namePosPair) => getExec(namePosPair)) + execNamePosPairs.map((posPairs) => getExec(posPairs[0], posPairs[1])) )) as SerializedExec[]; const [