@@ -6,7 +6,6 @@ import {
6 SingleColumn,
6 SingleColumn,
10 getAllPosts,
9 getAllPosts,
11 generateDisplayDate,
10 generateDisplayDate,
12 formatDate,
11 formatDate,
@@ -14,12 +13,15 @@ import {
14import Header from "../../components/Header";
13import Header from "../../components/Header";
15import Footer from "../../components/Footer";
14import Footer from "../../components/Footer";
16import Sidebar from "../../components/Sidebar";
15import Sidebar from "../../components/Sidebar";
16+import EcosystemSidebar from "../../components/ecosystem/EcosystemSidebar";
17+import SpotlightArchive from "../../components/ecosystem/SpotlightArchive";
17import Post from "../../components/ecosystem/Post";
18import Post from "../../components/ecosystem/Post";
18import classnames from "classnames";
19import classnames from "classnames";
19import Link from "next/link";
20import Link from "next/link";
20import fs from "fs";
21import fs from "fs";
21import path from "path";
22import path from "path";
22import Contact from "../../components/Contact";
23import Contact from "../../components/Contact";
24+import { matchEcosystemPost } from "../../lib/lib";
24export default function Ecosystem({
26export default function Ecosystem({
@@ -36,16 +38,24 @@ export default function Ecosystem({
37 const { type } = router.query;
39 const { type } = router.query;
41+ // Route ?type=archive to below component;
42+ // otherwise, show directory of ecosystem type
43+ // If no param, we show the spotlight for the month
39 if (type === "archive") {
44 if (type === "archive") {
40 return <SpotlightArchive posts={posts} search={search} />;
45 return <SpotlightArchive posts={posts} search={search} />;
48+ const spotlight = type === undefined;
43 let title;
50 let title;
44 if (type) {
51 if (type) {
45 switch (type) {
52 switch (type) {
46 case "applications":
53 case "applications":
47 title = "Applications • Ecosystem";
54 title = "Applications • Ecosystem";
57+ title = "Groups • Ecosystem";
49 case "marketplaces":
59 case "marketplaces":
50 title = "Marketplaces • Ecosystem";
60 title = "Marketplaces • Ecosystem";
@@ -88,21 +98,19 @@ export default function Ecosystem({
88 </Sidebar>
98 </Sidebar>
90 className={classnames("w-full", {
100 className={classnames("w-full", {
91− "max-w-prose": type === undefined,
101+ "max-w-prose": spotlight,
94− {type === undefined && (
104+ {/* Default layout */}
95− <h3>{`Ecosystem Spotlight - ${post.title}`}</h3>
105+ {spotlight && (
97− {type === undefined && (
107+ <h3>{`Ecosystem Spotlight - ${post.title}`}</h3>
99 <Post post={post} />
108 <Post post={post} />
100 <Link href="/ecosystem/?type=archive" passHref>
109 <Link href="/ecosystem/?type=archive" passHref>
101 <a className="button-lg bg-wall-600 text-white w-fit">
110 <a className="button-lg bg-wall-600 text-white w-fit">
102 Spotlight Archive
111 Spotlight Archive
106 <div className="pt-36">
114 <div className="pt-36">
107 <h3 className="pb-2">Urbit Monthly</h3>
115 <h3 className="pb-2">Urbit Monthly</h3>
108 <p className="pb-8">
116 <p className="pb-8">
@@ -113,126 +121,36 @@ export default function Ecosystem({
116−
124+ {/* Ecosystem type layouts */}
118 className={classnames("grid gap-12 w-full", {
126 className={classnames("grid gap-12 w-full", {
119 "grid-cols-2 md:grid-cols-3": type == "organizations" || type == "marketplaces",
127 "grid-cols-2 md:grid-cols-3": type == "organizations" || type == "marketplaces",
120 "grid-cols-1": type === "podcasts" || type === "articles",
128 "grid-cols-1": type === "podcasts" || type === "articles",
121 "grid-cols-1 md:grid-cols-1 lg:grid-cols-1 xl:grid-cols-2":
129 "grid-cols-1 md:grid-cols-1 lg:grid-cols-1 xl:grid-cols-2":
122 type === "applications" || type === "groups",
130 type === "applications" || type === "groups",
123− hidden: type === undefined,
131+ hidden: spotlight,
126 {type === "organizations" &&
134 {type === "organizations" &&
127− organizations.map((org) => (
128− <Link href={`/organizations/${org.slug}`}>
135+ <Organizations dir={organizations} />
129− <div className="flex flex-col space-y-4 items-center cursor-pointer hover:opacity-90">
130− <img className="w-36 rounded-xl" src={org.image} />
131− <p className="text-center font-bold">{org.title}</p>
136 {type === "applications" &&
138 {type === "applications" &&
137− applications.map((app) => (
139+ <Applications dir={applications} />
138− <Link href={`/applications/${app.ship}/${app.slug}`}>
139− <div className="flex space-x-4 items-center cursor-pointer hover:opacity-90">
141− className="h-36 w-36 rounded-xl items-center justify-center shrink-0 overflow-hidden"
143− backgroundColor: app?.bgColor || "rgba(0,0,0,0)",
148− className="items-center h-36 w-36"
154− <p className="text-left font-bold">{app.title}</p>
155− <p className="text-left text-wall-400 font-light">
162 {type === "groups" &&
141 {type === "groups" &&
163− groups.map((group) => (
142+ <Groups dir={groups} />
164− <Link href={`/groups/${group.ship}/${group.slug}`}>
165− <div className="flex space-x-4 items-center cursor-pointer hover:opacity-90">
167− className="h-36 w-36 rounded-xl items-center justify-center shrink-0 overflow-hidden"
169− backgroundColor: group?.tile?.startsWith("#")
174− {!group?.tile?.startsWith("#") && (
176− className="items-center h-36 w-36"
182− <p className="text-left font-bold">{group.title}</p>
183− <p className="text-left text-wall-400 font-light">
190 {type === "marketplaces" &&
144 {type === "marketplaces" &&
191− marketplaces.map((market) => (
192− <Link href={`/marketplaces/${market.slug}`}>
145+ <Marketplaces dir={marketplaces} />
193− <div className="flex flex-col space-y-4 justify-center items-center cursor-pointer hover:opacity-90">
194− <img className="w-36 rounded-xl" src={market.image} />
195− <p className="text-center font-bold">{market.title}</p>
199 {type === "podcasts" &&
147 {type === "podcasts" &&
200− podcasts.map((pod) => (
148+ <Podcasts dir={podcasts} />
201− <Link href={`/podcasts/${pod.slug}`}>
202− <div className="flex cursor-pointer space-x-4 items-center hover:opacity-90">
203− <img className="w-28" src={pod.image} />
204− <div className="flex flex-col space-y-2 min-w-0">
205− <p className="font-bold">{pod.podcast}</p>
206− <p className="min-w-0 min-h-0 leading-5 ">
209− <p className="text-wall-400">
210− {formatDate(generateDisplayDate(pod.date))}
217 {type === "articles" &&
151 {type === "articles" &&
218− articles.map((article) => (
152+ <Articles dir={articles} />
219− <Link href={`/articles/${article.slug}`}>
153+ }
220− <div className="flex cursor-pointer space-x-4 items-center hover:opacity-90">
221− <img className="w-28" src={article.image} />
222− <div className="flex flex-col space-y-2 min-w-0">
223− <p className="font-bold">{article.publication}</p>
224− <p className="min-w-0 min-h-0 leading-5 ">
227− <p className="text-wall-400">
228− {formatDate(generateDisplayDate(article.date))}
@@ -243,153 +161,136 @@ export default function Ecosystem({
246−function ActiveLink({ children, href, className, currentPath }) {
164+const Organizations = ({ dir }) => {
247− // special casing this behaviour which overloads one nav
248− const archive = Boolean(
249− currentPath === "/ecosystem?type=archive" && href === "/ecosystem"
251− const activeClassName = classnames({
252− "text-wall-800": currentPath === href || archive,
253− "text-wall-400": currentPath !== href && !archive,
256− return (
165+ return dir.map((org) => (
257− <Link href={href} passHref>
166+ <Link href={`/organizations/${org.slug}`}>
258− <a className={`${className} ${activeClassName}`}>{children}</a>
167+ <div className="flex flex-col space-y-4 items-center cursor-pointer hover:opacity-90">
168+ <img className="w-36 rounded-xl" src={org.image} />
169+ <p className="text-center font-bold">{org.title}</p>
263−function EcosystemSidebar() {
175+const Applications = ({ dir }) => {
264− const router = useRouter();
265− let currentPath = router.asPath;
266− return (
176+ return dir.map((app) => (
177+ <Link href={`/applications/${app.ship}/${app.slug}`}>
267− <div className="flex flex-col space-y-4 pr-24">
178+ <div className="flex space-x-4 items-center cursor-pointer hover:opacity-90">
268− <ActiveLink
179+ <div
269− currentPath={currentPath}
180+ className="h-36 w-36 rounded-xl items-center justify-center shrink-0 overflow-hidden"
270− className="type-ui"
181+ style={{
271− href="/ecosystem"
182+ backgroundColor: app?.bgColor || "rgba(0,0,0,0)",
274− </ActiveLink>
185+ {app?.image && (
275− <ActiveLink
186+ <img
276− currentPath={currentPath}
278− href="/ecosystem?type=organizations"
283− currentPath={currentPath}
284− className="type-ui"
187+ className="items-center h-36 w-36"
285− href="/ecosystem?type=applications"
188+ src={app.image}
288− </ActiveLink>
191+ </div>
290− currentPath={currentPath}
291− className="type-ui"
192+ <div className="">
292− href="/ecosystem?type=groups"
193+ <p className="text-left font-bold">{app.title}</p>
293− >
194+ <p className="text-left text-wall-400 font-light">
294− Groups
195+ {app.description}
297− currentPath={currentPath}
299− href="/ecosystem?type=marketplaces"
304− currentPath={currentPath}
305− className="mr-5 type-ui"
306− href="/ecosystem?type=podcasts"
309− </ActiveLink>
198+ </div>
311− <ActiveLink
203+const Groups = ({ dir }) => {
312− currentPath={currentPath}
204+ return dir.map((group) => (
313− className="mr-5 type-ui"
205+ <Link href={`/groups/${group.ship}/${group.slug}`}>
314− href="/ecosystem?type=articles"
206+ <div className="flex space-x-4 items-center cursor-pointer hover:opacity-90">
208+ className="h-36 w-36 rounded-xl items-center justify-center shrink-0 overflow-hidden"
210+ backgroundColor: group?.tile?.startsWith("#")
215+ {!group?.tile?.startsWith("#") && (
217+ className="items-center h-36 w-36"
223+ <p className="text-left font-bold">{group.title}</p>
224+ <p className="text-left text-wall-400 font-light">
317− </ActiveLink>
228+ </div>
233+const Marketplaces = ({ dir }) => {
234+ return dir.map((market) => (
235+ <Link href={`/marketplaces/${market.slug}`}>
236+ <div className="flex flex-col space-y-4 justify-center items-center cursor-pointer hover:opacity-90">
237+ <img className="w-36 rounded-xl" src={market.image} />
238+ <p className="text-center font-bold">{market.title}</p>
244+const Podcasts = ({ dir }) => {
245+ return dir.map((pod) => (
246+ <Link href={`/podcasts/${pod.slug}`}>
247+ <div className="flex cursor-pointer space-x-4 items-center hover:opacity-90">
248+ <img className="w-28" src={pod.image} />
249+ <div className="flex flex-col space-y-2 min-w-0">
250+ <p className="font-bold">{pod.podcast}</p>
251+ <p className="min-w-0 min-h-0 leading-5 ">
254+ <p className="text-wall-400">
255+ {formatDate(generateDisplayDate(pod.date))}
324−function SpotlightArchive({ posts, search }) {
325− const post = {
263+const Articles = ({ dir }) => {
326− title: "Spotlight Archive",
264+ return dir.map((article) => (
327− description: "The archive of ecosystem spotlights.",
265+ <Link href={`/articles/${article.slug}`}>
332− <title>Archive • Spotlight • Urbit</title>
335− <IntraNav ourSite="https://urbit.org" search={search} />
337− <Header search={search} />
339− <div className="measure">
343− <Section className="flex">
345− <EcosystemSidebar />
348− <h3 className="mb-12">Spotlight Archive</h3>
349− {posts.map((post) => {
351− <div key={post.slug} className="mb-24 cursor-pointer">
266+ <div className="flex cursor-pointer space-x-4 items-center hover:opacity-90">
352− <Link href={`/ecosystem/spotlight/${post.slug}`}>
267+ <img className="w-28" src={article.image} />
353− <div>
268+ <div className="flex flex-col space-y-2 min-w-0">
269+ <p className="font-bold">{article.publication}</p>
270+ <p className="min-w-0 min-h-0 leading-5 ">
354− <h3 className="text-green-400">{post.title}</h3>
273+ <p className="text-wall-400">
355− <div className="type-ui mt-2">
274+ {formatDate(generateDisplayDate(article.date))}
356− {["featured-1", "featured-2", "featured-3"].map(
275+ </p>
357− (feat, i) => {
276+ </div>
358− if (post?.[feat]) {
277+ </div>
359− return (
278+ </Link>
362− <span>{post[feat].title}</span>
382−export async function getStaticProps({}) {
283+export async function getStaticProps() {
383 const posts = getAllPosts(
284 const posts = getAllPosts(
384 ["title", "date", "slug", "featured-1", "featured-2", "featured-3"],
285 ["title", "date", "slug", "featured-1", "featured-2", "featured-3"],
385 "ecosystem/spotlight",
286 "ecosystem/spotlight",
388− let post = getAllPosts(
289+ const post = matchEcosystemPost(getAllPosts(
389 ["title", "date", "featured-1", "featured-2", "featured-3"],
290 ["title", "date", "featured-1", "featured-2", "featured-3"],
390 "ecosystem/spotlight",
291 "ecosystem/spotlight",
393 const marketplaces = getAllPosts(["title", "image", "slug"], "marketplaces");
294 const marketplaces = getAllPosts(["title", "image", "slug"], "marketplaces");
394 const podcasts = getAllPosts(
295 const podcasts = getAllPosts(
395 ["title", "image", "date", "podcast", "slug"],
296 ["title", "image", "date", "podcast", "slug"],
@@ -444,26 +345,6 @@ export async function getStaticProps({}) {
444 return nameA < nameB ? -1 : 1;
345 return nameA < nameB ? -1 : 1;
447− ["featured-1", "featured-2", "featured-3"].forEach((feat) => {
449− const matchedPost = [
450− ...applications.map((e) => ({ ...e, type: "Application" })),
451− ...organizations.map((e) => ({ ...e, type: "Organization" })),
452− ...podcasts.map((e) => ({ ...e, type: "Podcast" })),
453− ...articles.map((e) => ({ ...e, type: "Article" })),
454− ...marketplaces.map((e) => ({ ...e, type: "Marketplace" })),
455− ].filter((e) => e.title === post[feat].title)?.[0];
456− post[feat].image = post[feat]?.image || matchedPost?.image || null;
457− post[feat].type = matchedPost?.type || "Podcast";
458− post[feat].matchedPost = matchedPost || null;
459− post[feat].content = JSON.stringify(
461− post: { content: post[feat].content },