@@ -22,6 +22,7 @@ import IndexCard from "../components/ecosystem/IndexCard";
2222import fs from "fs";
2323import path from "path";
2424import Meta from "../components/Meta";
25+import { matchEcosystemPost } from "../lib/lib";
2526
2627export default function Home({
2728 posts,
@@ -316,85 +317,12 @@ export async function getStaticProps() {
316317 "date"
317318 );
318319
319− // Pull all latest ecosystem information
320− const ecosystem = getAllPosts(
320+ // Latest ecosystem report with matched post metadata
321+ const ecosystem = matchEcosystemPost(getAllPosts(
321322 ["date", "featured-1", "featured-2", "featured-3"],
322323 "ecosystem/spotlight",
323324 "date"
324− )[0];
325−
326− const articles = getAllPosts(
327− ["title", "image", "date", "podcast", "slug"],
328− "articles",
329− "date"
330− );
331−
332− const marketplaces = getAllPosts(["title", "image", "slug"], "marketplaces");
333− const podcasts = getAllPosts(
334− ["title", "image", "date", "podcast", "slug"],
335− "podcasts",
336− "date"
337− );
338− const organizations = getAllPosts(
339− ["title", "image", "slug"],
340− "organizations"
341− );
342− const applications = fs
343− .readdirSync(path.join(process.cwd(), "content/applications"), {
344− withFileTypes: true,
345− })
346− .filter((f) => f.isDirectory())
347− .map((dir) =>
348− getAllPosts(
349− ["title", "bgColor", "image", "slug", "description"],
350− `applications/${dir.name}`
351− )
352− .map((e) => ({ ...e, ship: dir.name }))
353− .flat()
354− )
355− .flat()
356− .sort((a, b) => {
357− const nameA = a.title.toLowerCase();
358− const nameB = b.title.toLowerCase();
359− return nameA < nameB ? -1 : 1;
360− });
361−
362− const groups = fs
363− .readdirSync(path.join(process.cwd(), "content/groups"), {
364− withFileTypes: true,
365− })
366− .filter((f) => f.isDirectory())
367− .map((dir) =>
368− getAllPosts(
369− ["title", "tile", "slug", "description"],
370− `groups/${dir.name}`
371− )
372− .map((e) => ({ ...e, ship: dir.name }))
373− .flat()
374− )
375− .flat()
376− .sort((a, b) => {
377− const nameA = a.title.toLowerCase();
378− const nameB = b.title.toLowerCase();
379− return nameA < nameB ? -1 : 1;
380− });
381−
382− ["featured-1", "featured-2", "featured-3"].forEach((feat) => {
383− if (ecosystem?.[feat]) {
384− const matchedPost = [
385− ...articles.map((e) => ({ ...e, type: "Article" })),
386− ...applications.map((e) => ({ ...e, type: "Application" })),
387− ...organizations.map((e) => ({ ...e, type: "Organization" })),
388− ...podcasts.map((e) => ({ ...e, type: "Podcast" })),
389− ...marketplaces.map((e) => ({ ...e, type: "Marketplace" })),
390− ...groups.map((e) => ({ ...e, type: "Group" }))
391− ].filter((e) => e.title === ecosystem[feat].title)?.[0];
392− ecosystem[feat].image =
393− ecosystem[feat].image || matchedPost?.image || null;
394− ecosystem[feat].type = matchedPost?.type || "Podcast";
395− ecosystem[feat].matchedPost = matchedPost || null;
396− }
397− });
325+ )[0]);
398326
399327 // Latest grants
400328 const basePath = path.join(process.cwd(), 'content/grants')