on master help sign in
Merge pull request #1726 from urbit/mp/eco-groups

ecosystem: show groups

commit96528f5b4a0d906f2d822ace6aaff6490f1e4ef9 authorGordon <gordon.cieplak@urbit.org> dateTue 16 Aug 2022, 16:36 (4 years ago) parentb7451abc1fe23f
1 file changed+65−2
pages/ecosystem/index.js+65−2
pages/ecosystem/index.js+65−2
@@ -25,6 +25,7 @@ export default function Ecosystem({
2525 post,
2626 posts,
2727 applications,
28+ groups,
2829 marketplaces,
2930 organizations,
3031 podcasts,
@@ -113,7 +114,7 @@ export default function Ecosystem({
113114 "grid-cols-2 md:grid-cols-3": type !== "podcasts",
114115 "grid-cols-1": type === "podcasts",
115116 "grid-cols-1 md:grid-cols-1 lg:grid-cols-1 xl:grid-cols-2":
116− type === "applications",
117+ type === "applications" || type === "groups",
117118 hidden: type === undefined,
118119 })}
119120 >
@@ -153,6 +154,34 @@ export default function Ecosystem({
153154 </div>
154155 </Link>
155156 ))}
157+ {type === "groups" &&
158+ groups.map((group) => (
159+ <Link href={`/groups/${group.ship}/${group.slug}`}>
160+ <div className="flex space-x-4 items-center cursor-pointer hover:opacity-90">
161+ <div
162+ className="h-36 w-36 rounded-xl items-center justify-center shrink-0 overflow-hidden"
163+ style={{
164+ backgroundColor: group?.tile?.startsWith("#")
165+ ? group?.tile
166+ : "rgba(0,0,0,0)",
167+ }}
168+ >
169+ {!group?.tile?.startsWith("#") && (
170+ <img
171+ className="items-center h-36 w-36"
172+ src={group.tile}
173+ />
174+ )}
175+ </div>
176+ <div className="">
177+ <p className="text-left font-bold">{group.title}</p>
178+ <p className="text-left text-wall-400 font-light">
179+ {group.description}
180+ </p>
181+ </div>
182+ </div>
183+ </Link>
184+ ))}
156185 {type === "marketplaces" &&
157186 marketplaces.map((market) => (
158187 <Link href={`/marketplaces/${market.slug}`}>
@@ -232,6 +261,13 @@ function EcosystemSidebar() {
232261 >
233262 Applications
234263 </ActiveLink>
264+ <ActiveLink
265+ currentPath={currentPath}
266+ className="type-ui"
267+ href="/ecosystem?type=groups"
268+ >
269+ Groups
270+ </ActiveLink>
235271 <ActiveLink
236272 currentPath={currentPath}
237273 className="type-ui"
@@ -348,6 +384,25 @@ export async function getStaticProps({}) {
348384 const nameB = b.title.toLowerCase();
349385 return nameA < nameB ? -1 : 1;
350386 });
387+ const groups = fs
388+ .readdirSync(path.join(process.cwd(), "content/groups"), {
389+ withFileTypes: true,
390+ })
391+ .filter((f) => f.isDirectory())
392+ .map((dir) =>
393+ getAllPosts(
394+ ["title", "tile", "slug", "description"],
395+ `groups/${dir.name}`
396+ )
397+ .map((e) => ({ ...e, ship: dir.name }))
398+ .flat()
399+ )
400+ .flat()
401+ .sort((a, b) => {
402+ const nameA = a.title.toLowerCase();
403+ const nameB = b.title.toLowerCase();
404+ return nameA < nameB ? -1 : 1;
405+ });
351406
352407 ["featured-1", "featured-2", "featured-3"].forEach((feat) => {
353408 if (post?.[feat]) {
@@ -369,6 +424,14 @@ export async function getStaticProps({}) {
369424 });
370425
371426 return {
372− props: { posts, post, applications, marketplaces, podcasts, organizations },
427+ props: {
428+ posts,
429+ post,
430+ applications,
431+ groups,
432+ marketplaces,
433+ podcasts,
434+ organizations,
435+ },
373436 };
374437}