From 0338fb098e39e21af1868274bbdf82623acc9225 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Thu, 6 Jun 2024 16:29:58 +0000 Subject: [PATCH] [#315,ecosystem/cohere][s]: get basic landing page for cohere by copy paste of pip stuff. --- layouts/cohere.tsx | 113 +++++++++++++++++++++++++++++++++++++ lib/computeFields.ts | 1 + pages/ecosystem/cohere.tsx | 77 +++++++++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 layouts/cohere.tsx create mode 100644 pages/ecosystem/cohere.tsx diff --git a/layouts/cohere.tsx b/layouts/cohere.tsx new file mode 100644 index 00000000..b2cec725 --- /dev/null +++ b/layouts/cohere.tsx @@ -0,0 +1,113 @@ +// @ts-nocheck +import { + GlobeAltIcon, + LocationMarkerIcon, + UserCircleIcon, + BriefcaseIcon, + HashtagIcon +} from '@heroicons/react/solid'; + +export default function Profile({ children, ...frontMatter }) { + // const { title, url, locations, people, topic, activity, image } = frontMatter; + const { title, url, locations, people, topic, activity } = frontMatter; + const image = frontMatter.logo.cached_new; + + return ( +
+
+

+ {title} +

+
+
+ {/* details */} +
+
+ {url && ( +
+ + +
+ )} + {locations?.length > 0 && ( +
+ +
    + {locations.map((value, index) => { + return ( +
  • + {value} +
  • + ); + })} +
+
+ )} + {people?.length > 0 && ( +
+ +
    + {people.map((value, index) => { + return ( +
  • + {value + (index === people.length - 1 ? '' : ',')} +
  • + ); + })} +
+
+ )} + {activity?.length > 0 && ( +
+ +
    + {activity.map((value, index) => { + return ( +
  • + {value + (index === activity.length - 1 ? '' : ',')} +
  • + ); + })} +
+
+ )} + {topic?.length > 0 && ( +
+ +
    + {topic.map((value, index) => { + return ( +
  • + {value + (index === topic.length - 1 ? '' : ',')} +
  • + ); + })} +
+
+ )} +
+
+

+ Organization information +

+
{children}
+
+
+ {/* image */} +
+
+ {title} +
+
+
+
+ ); +} diff --git a/lib/computeFields.ts b/lib/computeFields.ts index 0e9c44c7..5f7d5a2d 100644 --- a/lib/computeFields.ts +++ b/lib/computeFields.ts @@ -42,6 +42,7 @@ const computeFields = async ({ if (frontMatter.layout) return frontMatter.layout; if (urlPath.startsWith("blog/")) return "blog"; if (urlPath.includes("ecosystem/pip/profiles")) return "profile"; + if (urlPath.includes("ecosystem/cohere/profiles")) return "cohere"; // if (urlPath.startsWith("docs/")) return "docs"; return "docs"; // TODO default layout from config? })(); diff --git a/pages/ecosystem/cohere.tsx b/pages/ecosystem/cohere.tsx new file mode 100644 index 00000000..dd6deea1 --- /dev/null +++ b/pages/ecosystem/cohere.tsx @@ -0,0 +1,77 @@ +import React from "react"; +import { GetStaticProps, GetStaticPropsResult } from "next"; + +import clientPromise from "@/lib/mddb.mjs"; + +import ProfileSearch from "@/components/custom/ProfileSearch" +import MdxComponent from "@/components/MdxComponent"; + +import type { CustomAppProps } from "../_app"; +import { hasRequiredProfileFields } from "@/lib/temp/hasRequiredProfileFields"; + + +interface Props extends CustomAppProps { + profiles: any; // TODO: type + topics: any; // TODO: type +} + +const HomePage: React.FC = ({ profiles, topics }) => { + return ( + <> +
+ {profiles.map((profile: any, idx) => ( +

{profile.title}

+ ))} +
+
+

+ Directory +

+
Explore the directory of organizations, communities, and initiatives who are active in or close to the ecosystem.
+ +
+ + ); +} + +export const getStaticProps: GetStaticProps = async (): Promise< + GetStaticPropsResult +> => { + + const mddb = await clientPromise; + + // TODO: this should really be a library function ... + const profileFiles = await mddb.getFiles({ folder: "ecosystem/cohere/profiles" }); + const profiles = profileFiles.reduce((acc, file) => { + acc.push({ + ...file.metadata, + image: file.metadata.image?.url ?? file.metadata.image, + urlPath: '/' + file.url_path, + }); + return acc; + }, []); + + const topicFiles = await mddb.getFiles({ folder: "topics" }); + const topics = topicFiles.map((file) => { + return { + ...file.metadata, + urlPath: file.url_path, + }; + }); + + return { + props: { + meta: { + urlPath: "/", + showToc: false, + showEditLink: false, + showSidebar: false, + showComments: false, + }, + profiles, + topics, + }, + }; +}; + +export default HomePage;