@@ -0,0 +1,132 @@
1+// Single page per organisation
2+// Needs to have *associated ships* by which it polls content/applications for applications it "owns"
3+// Needs to look for its title in ecosystem/spotlight
4+import { getAllPosts, getPostBySlug, getPostSlugs } from "../../lib/lib";
5+import BasicPage from "../../components/ecosystem/BasicPage";
6+import { Markdown } from "foundation-design-system";
7+import Link from "next/link";
8+import fs from "fs";
9+import path from "path";
10+
11+export default function Organization({
12+ post,
13+ markdown,
14+ search,
15+ index,
16+ group,
17+ applications = [],
18+ spotlights = [],
19+}) {
20+ return (
21+ <BasicPage
22+ section="Organizations"
23+ post={post}
24+ group={group}
25+ markdown={markdown}
26+ search={search}
27+ index={index}
28+ >
29+ {spotlights.length > 0 && (
30+ <p>
31+ Featured in{" "}
32+ {spotlights.map((e, i) => (
33+ <>
34+ {i ? ", " : ""}
35+ <Link href={`/ecosystem/spotlight/${e.slug}`}>{e.title}</Link>
36+ </>
37+ ))}
38+ </p>
39+ )}
40+ {applications.length > 0 && (
41+ <>
42+ <h3>Applications</h3>
43+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
44+ {applications.map((app) => (
45+ <Link href={`/applications/${app.ship}/${app.slug}`}>
46+ <div className="flex flex-col space-y-4 cursor-pointer">
47+ <div
48+ className="overflow-hidden rounded-xl"
49+ style={{ backgroundColor: app.bgColor || "rgba(0,0,0,0)" }}
50+ >
51+ {app.image && (
52+ <img src={app.image} className="h-full w-full" />
53+ )}
54+ </div>
55+ <p className="text-center font-bold font-xl">{app.title}</p>
56+ </div>
57+ </Link>
58+ ))}
59+ </div>
60+ </>
61+ )}
62+ </BasicPage>
63+ );
64+}
65+
66+export async function getStaticProps({ params }) {
67+ const post = getPostBySlug(
68+ params.slug,
69+ ["title", "slug", "URL", "image", "ships", "group", "content"],
70+ "organizations"
71+ );
72+
73+ const spotlights = getAllPosts(
74+ ["title", "slug", "featured"],
75+ "ecosystem/spotlight"
76+ ).filter((e) => e.featured.includes(post.title));
77+
78+ const applications = post.ships
79+ .map((ship) => {
80+ let apps = [];
81+ if (
82+ fs.existsSync(path.join(process.cwd(), "content/applications", ship))
83+ ) {
84+ apps = getAllPosts(
85+ ["title", "image", "bgColor", "slug"],
86+ `applications/${ship}`
87+ ).map((e) => ({ ...e, ship }));
88+ }
89+ return apps;
90+ })
91+ .flat();
92+
93+ let group = null;
94+ const groupHost = post?.group?.slice(0, post.group.indexOf("/"));
95+ const groupName = post?.group?.slice(post.group.indexOf("/"));
96+ if (
97+ post.group &&
98+ fs.existsSync(path.join(process.cwd(), "content/groups", groupHost)) &&
99+ fs.existsSync(
100+ path.join(process.cwd(), "content/groups", groupHost, `${groupName}.md`)
101+ )
102+ ) {
103+ group = getPostBySlug(groupName, ["title"], `groups/${groupHost}`);
104+ }
105+ let { index } = post?.extra || { index: null };
106+
107+ if (index === undefined) {
108+ index = null;
109+ }
110+
111+ const markdown = JSON.stringify(Markdown.parse({ post }));
112+ return {
113+ props: { post, markdown, spotlights, applications, group, index },
114+ };
115+}
116+
117+export async function getStaticPaths() {
118+ const posts = getPostSlugs("organizations");
119+
120+ const slugs = posts.map((e) => e.slice(0, -3));
121+
122+ return {
123+ paths: slugs.map((post) => {
124+ return {
125+ params: {
126+ slug: post,
127+ },
128+ };
129+ }),
130+ fallback: false,
131+ };
132+}