diff --git a/content/team/execs/06-codey.md b/content/team/execs/codey.md similarity index 100% rename from content/team/execs/06-codey.md rename to content/team/execs/codey.md diff --git a/content/team/execs/03-dina-orucevic.md b/content/team/execs/dina-orucevic.md similarity index 100% rename from content/team/execs/03-dina-orucevic.md rename to content/team/execs/dina-orucevic.md diff --git a/content/team/execs/04-eden-chan.md b/content/team/execs/eden-chan.md similarity index 100% rename from content/team/execs/04-eden-chan.md rename to content/team/execs/eden-chan.md diff --git a/content/team/execs/02-eric-huang.md b/content/team/execs/eric-huang.md similarity index 100% rename from content/team/execs/02-eric-huang.md rename to content/team/execs/eric-huang.md diff --git a/content/team/execs/01-juthika-hoque.md b/content/team/execs/juthika-hoque.md similarity index 100% rename from content/team/execs/01-juthika-hoque.md rename to content/team/execs/juthika-hoque.md diff --git a/content/team/execs/05-raymond-li.md b/content/team/execs/raymond-li.md similarity index 100% rename from content/team/execs/05-raymond-li.md rename to content/team/execs/raymond-li.md diff --git a/lib/team.ts b/lib/team.ts index 0467526a..cc1323cc 100644 --- a/lib/team.ts +++ b/lib/team.ts @@ -33,11 +33,9 @@ export interface Metadata { image: string; } -export async function getExecNames() { +export async function getExecNamePosPairs() { if (process.env.USE_LDAP?.toLowerCase() !== "true") { - return (await readdir(EXECS_PATH)) - .filter((name) => name.endsWith(fileType)) - .map((name) => name.slice(0, -1 * fileType.length)); + return [["codey", "mascot"]]; } const url = "ldap://ldap1.csclub.uwaterloo.ca"; @@ -46,7 +44,7 @@ export async function getExecNames() { // position: name const execMembers: { [name: string]: string } = {}; - let formattedExec: string[] = []; + let formattedExec: [string, string][] = []; try { await client.bind("", ""); @@ -62,7 +60,7 @@ export async function getExecNames() { searchEntries.forEach((item) => { if (typeof item.position === "string" && item.position in execPositions) { execMembers[item.position] = item.cn as string; - } else if (typeof item.position === "object") { + } else if (item.position instanceof Array) { item.position.forEach((p) => { if ((p as string) in execPositions) { execMembers[p as string] = item.cn as string; @@ -71,14 +69,18 @@ export async function getExecNames() { } }); - formattedExec = positionNames.map( - (position, i) => - `0${i + 1}-${execMembers[position] - .split(" ")[0] - .toLowerCase()}-${execMembers[position].split(" ")[1].toLowerCase()}` - ); + formattedExec = positionNames.map((position) => { + return [ + `${execMembers[position].split(" ")[0].toLowerCase()}-${execMembers[ + position + ] + .split(" ")[1] + .toLowerCase()}`, + position, + ]; + }); - formattedExec = [...formattedExec, "06-codey"]; + formattedExec = [...formattedExec, ["codey", "mascot"]]; } finally { await client.unbind(); } @@ -86,11 +88,16 @@ export async function getExecNames() { return formattedExec; } -export async function getExec(fileName: string, convert = true) { +export async function getExec( + execNamePosPair: [string, string], + convert = true +) { let content, metadata; try { - const raw = await readFile(path.join(EXECS_PATH, `${fileName}${fileType}`)); + const raw = await readFile( + path.join(EXECS_PATH, `${execNamePosPair[0]}${fileType}`) + ); ({ content, data: metadata } = matter(raw)); const image = @@ -103,12 +110,13 @@ export async function getExec(fileName: string, convert = true) { }; } catch (err) { const firstName = - fileName.split("-")[1][0].toUpperCase() + fileName.split("-")[1].slice(1); + execNamePosPair[0].split("-")[0][0].toUpperCase() + + execNamePosPair[0].split("-")[0].slice(1); const lastName = - fileName.split("-")[2][0].toUpperCase() + fileName.split("-")[2].slice(1); + execNamePosPair[0].split("-")[1][0].toUpperCase() + + execNamePosPair[0].split("-")[1].slice(1); - const posOrder = fileName.split("-")[0][1]; - const posName = execPositions[positionNames[Number(posOrder) - 1]]; + const posName = execPositions[execNamePosPair[1]]; ({ content, metadata } = { content: "Coming soon!", metadata: { diff --git a/pages/about/team.tsx b/pages/about/team.tsx index 7ad1b552..18f33c29 100644 --- a/pages/about/team.tsx +++ b/pages/about/team.tsx @@ -11,7 +11,7 @@ import { TeamMemberCard } from "@/components/TeamMemberCard"; import { Title } from "@/components/Title"; import { getExec, - getExecNames, + getExecNamePosPairs, Metadata, getMemberImagePath, } from "@/lib/team"; @@ -140,10 +140,10 @@ async function getTeamWithImages(team: TeamMember[]) { } export const getStaticProps: GetStaticProps = async () => { - const execNames = await getExecNames(); + const execNamePosPairs = await getExecNamePosPairs(); const execs = (await Promise.all( - execNames.map((name) => getExec(name)) + execNamePosPairs.map((namePosPair) => getExec(namePosPair)) )) as SerializedExec[]; const [programme, website, systems, terminal] = await Promise.all([