Correct Dirents
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
4239131512
commit
c39b0036ad
|
@ -7,33 +7,17 @@ import { MDXRemoteSerializeResult } from "next-mdx-remote";
|
||||||
const EVENTS_PATH = path.join("content", "events");
|
const EVENTS_PATH = path.join("content", "events");
|
||||||
|
|
||||||
export async function getYears(): Promise<string[]> {
|
export async function getYears(): Promise<string[]> {
|
||||||
//return await fs.readdir(EVENTS_PATH, { withFileTypes: true }, (err, files)=>err ? console.log(err));
|
return (await fs.readdir(EVENTS_PATH, { withFileTypes: true })).map(
|
||||||
// return await fs.readdir(
|
(dirent) => dirent.name
|
||||||
// __dirname,
|
);
|
||||||
// { withFileTypes: true },
|
|
||||||
// (err: Error, files: string[]) => {
|
|
||||||
// if (err) console.log(err);
|
|
||||||
// else {
|
|
||||||
// files.forEach((file) => {
|
|
||||||
// console.log(file);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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[]> {
|
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 {
|
interface Metadata {
|
||||||
|
@ -70,7 +54,12 @@ export async function getEventsByTerm(
|
||||||
year: string,
|
year: string,
|
||||||
term: string
|
term: string
|
||||||
): Promise<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"))
|
.filter((name) => name.endsWith(".md"))
|
||||||
.map((name) => name.slice(0, -".md".length));
|
.map((name) => name.slice(0, -".md".length));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue