@@ -15,6 +15,8 @@ import GrantPreview from "../components/GrantPreview";
15import JoinGroup from "../components/JoinGroup";
15import JoinGroup from "../components/JoinGroup";
16import omit from "lodash.omit";
16import omit from "lodash.omit";
17import { getGrantsCategories, getGrantsTypes } from "../lib/lib";
17import { getGrantsCategories, getGrantsTypes } from "../lib/lib";
19+import { join } from 'path';
19function isArray(arr) {
21function isArray(arr) {
20 return Array.isArray(arr);
22 return Array.isArray(arr);
@@ -264,9 +266,8 @@ export default function Grants({ posts, categories, types, search }) {
264 <h5 className="text-wall-600 font-semibold my-2">Programs</h5>
266 <h5 className="text-wall-600 font-semibold my-2">Programs</h5>
265 <div className="flex flex-wrap items-center pb-2">
267 <div className="flex flex-wrap items-center pb-2">
267− className={`badge-lg mr-2 ${
268− !type ? "bg-black text-white" : "bg-wall-100 text-wall-500"
269+ className={`badge-lg mr-2 ${!type ? "bg-black text-white" : "bg-wall-100 text-wall-500"
270 onClick={() => push((({ type, ...obj }) => obj)(router.query))}
271 onClick={() => push((({ type, ...obj }) => obj)(router.query))}
272 All <div className="opacity-50 ml-2">{allCount}</div>
273 All <div className="opacity-50 ml-2">{allCount}</div>
@@ -288,11 +289,10 @@ export default function Grants({ posts, categories, types, search }) {
291− className={`badge-lg mr-2 ${
292+ className={`badge-lg mr-2 ${isOrIsIn(each, type)
292− isOrIsIn(each, type)
293− ? activeBg
293+ ? activeBg
294− : "bg-wall-100 text-wall-500"
294+ : "bg-wall-100 text-wall-500"
296 onClick={() => push({ ...router.query, type: each })}
296 onClick={() => push({ ...router.query, type: each })}
@@ -365,11 +365,18 @@ export default function Grants({ posts, categories, types, search }) {
365export async function getStaticProps() {
365export async function getStaticProps() {
366 const categories = getGrantsCategories();
366 const categories = getGrantsCategories();
367 const types = getGrantsTypes();
367 const types = getGrantsTypes();
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) => {
368− const posts = getAllPosts(
371+ return getAllPosts(
369− ["title", "slug", "date", "description", "extra", "taxonomies"],
372+ ["title", "slug", "date", "description", "extra", "taxonomies"],
370− "grants",
373+ `grants/${year.name}`,
376+ }).flat().sort((a, b) => {
377+ return a.title.toLowerCase().localeCompare(b.title.toLowerCase())
375 posts: posts,
382 posts: posts,