@@ -15,6 +15,8 @@ import GrantPreview from "../components/GrantPreview";
1515import JoinGroup from "../components/JoinGroup";
1616import omit from "lodash.omit";
1717import { getGrantsCategories, getGrantsTypes } from "../lib/lib";
18+import fs from 'fs';
19+import { join } from 'path';
1820
1921function isArray(arr) {
2022 return Array.isArray(arr);
@@ -264,9 +266,8 @@ export default function Grants({ posts, categories, types, search }) {
264266 <h5 className="text-wall-600 font-semibold my-2">Programs</h5>
265267 <div className="flex flex-wrap items-center pb-2">
266268 <a
267− className={`badge-lg mr-2 ${
268− !type ? "bg-black text-white" : "bg-wall-100 text-wall-500"
269− }`}
269+ className={`badge-lg mr-2 ${!type ? "bg-black text-white" : "bg-wall-100 text-wall-500"
270+ }`}
270271 onClick={() => push((({ type, ...obj }) => obj)(router.query))}
271272 >
272273 All <div className="opacity-50 ml-2">{allCount}</div>
@@ -288,11 +289,10 @@ export default function Grants({ posts, categories, types, search }) {
288289 }
289290 return (
290291 <a
291− className={`badge-lg mr-2 ${
292− isOrIsIn(each, type)
293− ? activeBg
294− : "bg-wall-100 text-wall-500"
295− }`}
292+ className={`badge-lg mr-2 ${isOrIsIn(each, type)
293+ ? activeBg
294+ : "bg-wall-100 text-wall-500"
295+ }`}
296296 onClick={() => push({ ...router.query, type: each })}
297297 >
298298 {each}
@@ -365,11 +365,18 @@ export default function Grants({ posts, categories, types, search }) {
365365export async function getStaticProps() {
366366 const categories = getGrantsCategories();
367367 const types = getGrantsTypes();
368− const posts = getAllPosts(
369− ["title", "slug", "date", "description", "extra", "taxonomies"],
370− "grants",
371− "date"
372− );
368+ const basePath = join(process.cwd(), 'content/grants')
369+ const years = fs.readdirSync(basePath, { 'withFileTypes': true }).filter((f) => f.isDirectory());
370+ const posts = years.map((year) => {
371+ return getAllPosts(
372+ ["title", "slug", "date", "description", "extra", "taxonomies"],
373+ `grants/${year.name}`,
374+ "date"
375+ )
376+ }).flat().sort((a, b) => {
377+ return a.title.toLowerCase().localeCompare(b.title.toLowerCase())
378+ });
379+
373380 return {
374381 props: {
375382 posts: posts,