on master help sign in
pages: add marketplaces, organizations, podcasts
c21313dMatilde Park
pages/marketplaces/[slug].jsnew file+75
@@ -0,0 +1,75 @@
1+import { getAllPosts, getPostBySlug, getPostSlugs } from "../../lib/lib";
2+import BasicPage from "../../components/ecosystem/BasicPage";
3+import { Markdown } from "foundation-design-system";
4+import Link from "next/link";
5+
6+export default function Marketplace({
7+ post,
8+ markdown,
9+ search,
10+ index,
11+ spotlights = [],
12+}) {
13+ return (
14+ <BasicPage
15+ section="Marketplaces"
16+ post={post}
17+ markdown={markdown}
18+ search={search}
19+ index={index}
20+ >
21+ {spotlights.length > 0 && (
22+ <p>
23+ Featured in{" "}
24+ {spotlights.map((e, i) => (
25+ <>
26+ {i ? ", " : ""}
27+ <Link href={`/ecosystem/spotlight/${e.slug}`}>{e.title}</Link>
28+ </>
29+ ))}
30+ </p>
31+ )}
32+ </BasicPage>
33+ );
34+}
35+
36+export async function getStaticProps({ params }) {
37+ const post = getPostBySlug(
38+ params.slug,
39+ ["title", "slug", "URL", "image", "content"],
40+ "marketplaces"
41+ );
42+
43+ const spotlights = getAllPosts(
44+ ["title", "slug", "featured"],
45+ "ecosystem/spotlight"
46+ ).filter((e) => e.featured.includes(post.title));
47+
48+ let { index } = post?.extra || { index: null };
49+
50+ if (index === undefined) {
51+ index = null;
52+ }
53+
54+ const markdown = JSON.stringify(Markdown.parse({ post }));
55+ return {
56+ props: { post, markdown, spotlights, index },
57+ };
58+}
59+
60+export async function getStaticPaths() {
61+ const posts = getPostSlugs("marketplaces");
62+
63+ const slugs = posts.map((e) => e.slice(0, -3));
64+
65+ return {
66+ paths: slugs.map((post) => {
67+ return {
68+ params: {
69+ slug: post,
70+ },
71+ };
72+ }),
73+ fallback: false,
74+ };
75+}
pages/organizations/[slug].jsnew file+132
@@ -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+}
pages/podcasts/[slug].jsnew file+75
@@ -0,0 +1,75 @@
1+import { getAllPosts, getPostBySlug, getPostSlugs } from "../../lib/lib";
2+import BasicPage from "../../components/ecosystem/BasicPage";
3+import { Markdown } from "foundation-design-system";
4+import Link from "next/link";
5+
6+export default function Podcast({
7+ post,
8+ markdown,
9+ search,
10+ index,
11+ spotlights = [],
12+}) {
13+ return (
14+ <BasicPage
15+ section="Podcasts"
16+ post={post}
17+ markdown={markdown}
18+ search={search}
19+ index={index}
20+ >
21+ {spotlights.length > 0 && (
22+ <p>
23+ Featured in{" "}
24+ {spotlights.map((e, i) => (
25+ <>
26+ {i ? ", " : ""}
27+ <Link href={`/ecosystem/spotlight/${e.slug}`}>{e.title}</Link>
28+ </>
29+ ))}
30+ </p>
31+ )}
32+ </BasicPage>
33+ );
34+}
35+
36+export async function getStaticProps({ params }) {
37+ const post = getPostBySlug(
38+ params.slug,
39+ ["title", "slug", "URL", "podcast", "date", "image", "content"],
40+ "podcasts"
41+ );
42+
43+ const spotlights = getAllPosts(
44+ ["title", "slug", "featured"],
45+ "ecosystem/spotlight"
46+ ).filter((e) => e.featured.includes(post.title));
47+
48+ let { index } = post?.extra || { index: null };
49+
50+ if (index === undefined) {
51+ index = null;
52+ }
53+
54+ const markdown = JSON.stringify(Markdown.parse({ post }));
55+ return {
56+ props: { post, markdown, spotlights, index },
57+ };
58+}
59+
60+export async function getStaticPaths() {
61+ const posts = getPostSlugs("podcasts");
62+
63+ const slugs = posts.map((e) => e.slice(0, -3));
64+
65+ return {
66+ paths: slugs.map((post) => {
67+ return {
68+ params: {
69+ slug: post,
70+ },
71+ };
72+ }),
73+ fallback: false,
74+ };
75+}