Add placeholder

pull/403/head
Rebecca-Chou 10 months ago
parent 57f67bc8d1
commit 340dfa67b5
  1. 106
      lib/team.ts

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { readFile, readdir, access } from "fs/promises";
import path from "path";
@ -11,14 +12,22 @@ const EXECS_PATH = path.join("content", "team", "execs");
const fileType = ".md";
const { year, term } = getCurrentTerm();
const execPositions: { [name: string]: { order: number; name: string } } = {
president: { order: 1, name: "President" },
"vice-president": { order: 2, name: "Vice President" },
secretary: { order: 3, name: "Assistant Vice President" },
treasurer: { order: 4, name: "Treasurer" },
sysadmin: { order: 5, name: "System Administrator" },
const execPositions: { [name: string]: number } = {
president: 1,
"vice-president": 2,
secretary: 3,
treasurer: 4,
sysadmin: 5,
};
const positionNames: string[] = [
"President",
"Vice President",
"Assistant Vice President",
"Treasurer",
"System Administrator",
];
export interface execMembers {
name: string;
position: string;
@ -63,22 +72,17 @@ export async function getExecNames() {
})
.filter((item: execMembers) => item.position in execPositions)
.sort((item1: execMembers, item2: execMembers) => {
return (
execPositions[item1.position].order -
execPositions[item2.position].order
);
return execPositions[item1.position] - execPositions[item2.position];
});
formattedExec = execMembers.map(
(member) =>
`0${execPositions[member.position].order}-${member.name
`0${execPositions[member.position]}-${member.name
.split(" ")[0]
.toLowerCase()}-${member.name.split(" ")[1].toLowerCase()}`
);
formattedExec = [...formattedExec, "06-codey"];
// Add a new line???
} finally {
await client.unbind();
}
@ -87,45 +91,43 @@ export async function getExecNames() {
}
export async function getExec(fileName: string, convert = true) {
// const firstName =
// fileName.split("-")[1][0].toUpperCase() + fileName.split("-")[1].slice(1);
// const lastName =
// fileName.split("-")[2][0].toUpperCase() + fileName.split("-")[2].slice(1);
// const posOrder = fileName.split("-")[0];
// const pos = posDict[posOrder];
// let content, metadata;
// try {
const raw = await readFile(path.join(EXECS_PATH, `${fileName}${fileType}`));
const { content, data: metadata } = matter(raw);
const image =
(metadata.image as string | undefined) ??
(await getMemberImagePath(metadata.name));
return {
content: convert ? await serialize(content) : content,
metadata: { ...metadata, image } as Metadata,
};
// };
// } catch (err) {
// console.log(err);
// ({ content, metadata } = {
// content: "Coming soon!",
// metadata: {
// name: `${firstName} ${lastName}`,
// role: `${pos}`,
// },
// });
// const image = await getMemberImagePath(metadata.name);
// return {
// content: convert ? await serialize(content) : content,
// metadata: { ...metadata, image } as Metadata,
// };
// }
let content, metadata;
try {
const raw = await readFile(path.join(EXECS_PATH, `${fileName}${fileType}`));
({ content, data: metadata } = matter(raw));
const image =
(metadata.image as string | undefined) ??
(await getMemberImagePath(metadata.name));
return {
content: convert ? await serialize(content) : content,
metadata: { ...metadata, image } as Metadata,
};
} catch (err) {
const firstName =
fileName.split("-")[1][0].toUpperCase() + fileName.split("-")[1].slice(1);
const lastName =
fileName.split("-")[2][0].toUpperCase() + fileName.split("-")[2].slice(1);
const posOrder = fileName.split("-")[0][1];
const posName = positionNames[Number(posOrder) - 1];
({ content, metadata } = {
content: "Coming soon!",
metadata: {
name: `${firstName} ${lastName}`,
role: `${posName}`,
},
});
const image = await getMemberImagePath(metadata.name);
return {
content: convert ? await serialize(content) : content,
metadata: { ...metadata, image } as Metadata,
};
}
}
async function getImage(imgPath: string) {

Loading…
Cancel
Save