on master help sign in
organizations: show groups associated with ships, remove group prop
commit2a577be8f1ca4fc9cbb7fe57116db73d8030bc5b authorMatilde Park <matilde.park@urbit.org> dateWed 20 Jul 2022, 13:59 (4 years ago) parent898b44f
2 files changed+43−26
components/ecosystem/BasicPage.js−11 pages/organizations/[slug].js+43−15
components/ecosystem/BasicPage.js−11
@@ -17,7 +17,6 @@ import Footer from "../Footer";
1717export default function BasicPage({
1818 section,
1919 post,
20− group,
2120 markdown,
2221 search,
2322 children,
@@ -75,16 +74,6 @@ export default function BasicPage({
7574 </a>
7675 </div>
7776 )}
78− {(group || post?.group) && (
79− <div className="flex flex-col">
80− <p className="font-bold text-wall-400">Group</p>
81− <Link href={`/groups/${post.group}`} passHref>
82− <a className="text-green-400 text-sm font-semibold font-mono">
83− {group?.title || post.group}
84− </a>
85− </Link>
86− </div>
87− )}
8877 </div>
8978 {post?.URL && section === "Podcasts" && (
9079 <div className="button-lg bg-green-400 text-white cursor-pointer flex space-x-2">
pages/organizations/[slug].js+43−15
@@ -13,7 +13,7 @@ export default function Organization({
1313 markdown,
1414 search,
1515 index,
16− group,
16+ groups,
1717 applications = [],
1818 spotlights = [],
1919}) {
@@ -21,7 +21,6 @@ export default function Organization({
2121 <BasicPage
2222 section="Organizations"
2323 post={post}
24− group={group}
2524 markdown={markdown}
2625 search={search}
2726 index={index}
@@ -59,6 +58,35 @@ export default function Organization({
5958 </div>
6059 </>
6160 )}
61+ {groups.length > 0 && (
62+ <>
63+ <h3>Groups</h3>
64+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
65+ {groups.map((group) => (
66+ <Link href={`/groups/${group.ship}/${group.slug}`}>
67+ <div className="flex flex-col space-y-4 cursor-pointer">
68+ {group?.tile?.startsWith("#") ? (
69+ <div
70+ className="rounded-xl"
71+ style={{
72+ backgroundColor: group.tile,
73+ height: 164,
74+ width: 164,
75+ }}
76+ />
77+ ) : (
78+ <img
79+ src={group.tile}
80+ className="h-full w-full rounded-xl"
81+ />
82+ )}
83+ <p className="text-center font-bold font-xl">{group.title}</p>
84+ </div>
85+ </Link>
86+ ))}
87+ </div>
88+ </>
89+ )}
6290 </BasicPage>
6391 );
6492}
@@ -95,18 +123,18 @@ export async function getStaticProps({ params }) {
95123 })
96124 .flat();
97125
98− let group = null;
99− const groupHost = post?.group?.slice(0, post.group.indexOf("/"));
100− const groupName = post?.group?.slice(post.group.indexOf("/"));
101− if (
102− post.group &&
103− fs.existsSync(path.join(process.cwd(), "content/groups", groupHost)) &&
104− fs.existsSync(
105− path.join(process.cwd(), "content/groups", groupHost, `${groupName}.md`)
106− )
107− ) {
108− group = getPostBySlug(groupName, ["title"], `groups/${groupHost}`);
109− }
126+ const groups = post.ships
127+ .map((ship) => {
128+ let groups = [];
129+ if (fs.existsSync(path.join(process.cwd(), "content/groups", ship))) {
130+ groups = getAllPosts(["title", "tile", "slug"], `groups/${ship}`).map(
131+ (e) => ({ ...e, ship })
132+ );
133+ }
134+ return groups;
135+ })
136+ .flat();
137+
110138 let { index } = post?.extra || { index: null };
111139
112140 if (index === undefined) {
@@ -115,7 +143,7 @@ export async function getStaticProps({ params }) {
115143
116144 const markdown = JSON.stringify(Markdown.parse({ post }));
117145 return {
118− props: { post, markdown, spotlights, applications, group, index },
146+ props: { post, markdown, spotlights, applications, groups, index },
119147 };
120148}
121149