on master help sign in
Merge branch 'mp/ecosystem' of https://github.com/urbit/urbit.org into mp/ecosystem
9d6261aGordon
pages/ecosystem/spotlight/[slug].js+41
@@ -13,6 +13,8 @@ import Header from "../../../components/Header";
13import Footer from "../../../components/Footer";
13import Footer from "../../../components/Footer";
14import Post from "../../../components/ecosystem/Post";
14import Post from "../../../components/ecosystem/Post";
15import { getAllPosts, getPostBySlug } from "../../../lib/lib";
15import { getAllPosts, getPostBySlug } from "../../../lib/lib";
16+import fs from "fs";
17+import path from "path";
16
18
17export default function BasicPage({ post, markdown, search, index = false }) {
19export default function BasicPage({ post, markdown, search, index = false }) {
18 const router = useRouter();
20 const router = useRouter();
@@ -46,8 +48,47 @@ export async function getStaticProps({ params }) {
46 ["title", "slug", "date", "featured-1", "featured-2", "featured-3"],
48 ["title", "slug", "date", "featured-1", "featured-2", "featured-3"],
47 "ecosystem/spotlight"
49 "ecosystem/spotlight"
48 );
50 );
51+ const marketplaces = getAllPosts(["title", "image", "slug"], "marketplaces");
52+ const podcasts = getAllPosts(
53+ ["title", "image", "date", "podcast", "slug"],
54+ "podcasts",
55+ "date"
56+ );
57+ const organizations = getAllPosts(
58+ ["title", "image", "slug"],
59+ "organizations"
60+ );
61+ const applications = fs
62+ .readdirSync(path.join(process.cwd(), "content/applications"), {
63+ withFileTypes: true,
64+ })
65+ .filter((f) => f.isDirectory())
66+ .map((dir) =>
67+ getAllPosts(
68+ ["title", "bgColor", "image", "slug", "description"],
69+ `applications/${dir.name}`
70+ )
71+ .map((e) => ({ ...e, ship: dir.name }))
72+ .flat()
73+ )
74+ .flat()
75+ .sort((a, b) => {
76+ const nameA = a.title.toLowerCase();
77+ const nameB = b.title.toLowerCase();
78+ return nameA < nameB ? -1 : 1;
79+ });
80+
49 ["featured-1", "featured-2", "featured-3"].forEach((feat) => {
81 ["featured-1", "featured-2", "featured-3"].forEach((feat) => {
50 if (post?.[feat]) {
82 if (post?.[feat]) {
83+ const matchedPost = [
84+ ...applications.map((e) => ({ ...e, type: "Application" })),
85+ ...organizations.map((e) => ({ ...e, type: "Organization" })),
86+ ...podcasts.map((e) => ({ ...e, type: "Podcast" })),
87+ ...marketplaces.map((e) => ({ ...e, type: "Marketplace" })),
88+ ].filter((e) => e.title === post[feat].title)?.[0];
89+ post[feat].image = post[feat]?.image || matchedPost?.image || null;
90+ post[feat].type = matchedPost?.type || "Podcast";
91+ post[feat].matchedPost = matchedPost || null;
51 post[feat].content = JSON.stringify(
92 post[feat].content = JSON.stringify(
52 Markdown.parse({
93 Markdown.parse({
53 post: { content: post[feat].content },
94 post: { content: post[feat].content },