|
|
|
@ -7,33 +7,17 @@ import { MDXRemoteSerializeResult } from "next-mdx-remote"; |
|
|
|
|
const EVENTS_PATH = path.join("content", "events"); |
|
|
|
|
|
|
|
|
|
export async function getYears(): Promise<string[]> { |
|
|
|
|
//return await fs.readdir(EVENTS_PATH, { withFileTypes: true }, (err, files)=>err ? console.log(err));
|
|
|
|
|
// return await fs.readdir(
|
|
|
|
|
// __dirname,
|
|
|
|
|
// { withFileTypes: true },
|
|
|
|
|
// (err: Error, files: string[]) => {
|
|
|
|
|
// if (err) console.log(err);
|
|
|
|
|
// else {
|
|
|
|
|
// files.forEach((file) => {
|
|
|
|
|
// console.log(file);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// );
|
|
|
|
|
return (await fs.readdir(EVENTS_PATH, { withFileTypes: true })).map( |
|
|
|
|
(dirent) => dirent.name |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fs.readdir(__dirname, { withFileTypes: true }, (err, files) => { |
|
|
|
|
console.log("\nCurrent directory files:"); |
|
|
|
|
if (err) console.log(err); |
|
|
|
|
else { |
|
|
|
|
files.forEach((file) => { |
|
|
|
|
console.log(file); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
export async function getTermsByYear(year: string): Promise<string[]> { |
|
|
|
|
return await fs.readdir(path.join(EVENTS_PATH, year)); |
|
|
|
|
return ( |
|
|
|
|
await fs.readdir(path.join(EVENTS_PATH, year), { |
|
|
|
|
withFileTypes: true, |
|
|
|
|
}) |
|
|
|
|
).map((dirent) => dirent.name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
interface Metadata { |
|
|
|
@ -70,7 +54,12 @@ export async function getEventsByTerm( |
|
|
|
|
year: string, |
|
|
|
|
term: string |
|
|
|
|
): Promise<string[]> { |
|
|
|
|
return (await fs.readdir(path.join(EVENTS_PATH, year, term))) |
|
|
|
|
return ( |
|
|
|
|
await fs.readdir(path.join(EVENTS_PATH, year, term), { |
|
|
|
|
withFileTypes: true, |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
.map((dirent) => dirent.name) |
|
|
|
|
.filter((name) => name.endsWith(".md")) |
|
|
|
|
.map((name) => name.slice(0, -".md".length)); |
|
|
|
|
} |
|
|
|
|