Sort news years and news terms
This commit is contained in:
parent
a2a8900b74
commit
d15c5a0dd8
|
@ -6,6 +6,7 @@ import { MDXRemoteSerializeResult } from "next-mdx-remote";
|
||||||
import { serialize } from "next-mdx-remote/serialize";
|
import { serialize } from "next-mdx-remote/serialize";
|
||||||
|
|
||||||
const NEWS_PATH = path.join("content", "news");
|
const NEWS_PATH = path.join("content", "news");
|
||||||
|
const TERMS = ["winter", "spring", "fall"];
|
||||||
|
|
||||||
interface Metadata {
|
interface Metadata {
|
||||||
author: string;
|
author: string;
|
||||||
|
@ -20,7 +21,8 @@ export interface News {
|
||||||
export async function getNewsYears(): Promise<string[]> {
|
export async function getNewsYears(): Promise<string[]> {
|
||||||
return (await fs.readdir(NEWS_PATH, { withFileTypes: true }))
|
return (await fs.readdir(NEWS_PATH, { withFileTypes: true }))
|
||||||
.filter((dirent) => dirent.isDirectory())
|
.filter((dirent) => dirent.isDirectory())
|
||||||
.map((dirent) => dirent.name);
|
.map((dirent) => dirent.name)
|
||||||
|
.sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNewsTermsByYear(year: string): Promise<string[]> {
|
export async function getNewsTermsByYear(year: string): Promise<string[]> {
|
||||||
|
@ -29,8 +31,9 @@ export async function getNewsTermsByYear(year: string): Promise<string[]> {
|
||||||
withFileTypes: true,
|
withFileTypes: true,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.filter((dirent) => dirent.isDirectory())
|
.filter((dirent) => dirent.isDirectory() && TERMS.includes(dirent.name))
|
||||||
.map((dirent) => dirent.name);
|
.map((dirent) => dirent.name)
|
||||||
|
.sort((a, b) => TERMS.indexOf(a) - TERMS.indexOf(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getNewsByTerm(
|
export async function getNewsByTerm(
|
||||||
|
|
Loading…
Reference in New Issue