diff --git a/apps/codeforafrica/src/components/Partner/Partner.js b/apps/codeforafrica/src/components/AboutPageEntity/AboutPageEntity.js similarity index 75% rename from apps/codeforafrica/src/components/Partner/Partner.js rename to apps/codeforafrica/src/components/AboutPageEntity/AboutPageEntity.js index 8e479d56d..de8d8d390 100644 --- a/apps/codeforafrica/src/components/Partner/Partner.js +++ b/apps/codeforafrica/src/components/AboutPageEntity/AboutPageEntity.js @@ -8,8 +8,17 @@ import RelatedProjects from "@/codeforafrica/components/RelatedProjects"; import RichText from "@/codeforafrica/components/RichText"; import SectionDivider from "@/codeforafrica/components/SectionDivider"; -const Partner = React.forwardRef(function Partner( - { description, connect, relatedProjects, relatedProjectsTitle, name, logo }, +const Page = React.forwardRef(function Page( + { + description, + connect, + relatedProjects, + relatedProjectsTitle, + name, + logo, + user, + title, + }, ref, ) { return ( @@ -17,17 +26,20 @@ const Partner = React.forwardRef(function Partner(
renders unchanged 1`] = ` +exports[` renders unchanged 1`] = `
", () => { +describe("", () => { it("renders unchanged", () => { - const { container } = render(); + const { container } = render(); expect(container).toMatchSnapshot(); }); }); diff --git a/apps/codeforafrica/src/components/AboutPageEntity/index.js b/apps/codeforafrica/src/components/AboutPageEntity/index.js new file mode 100644 index 000000000..1e4246770 --- /dev/null +++ b/apps/codeforafrica/src/components/AboutPageEntity/index.js @@ -0,0 +1,3 @@ +import AboutPageEntity from "./AboutPageEntity"; + +export default AboutPageEntity; diff --git a/apps/codeforafrica/src/components/Partner/index.js b/apps/codeforafrica/src/components/Partner/index.js deleted file mode 100644 index e10539fb2..000000000 --- a/apps/codeforafrica/src/components/Partner/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import Partner from "./Partner"; - -export default Partner; diff --git a/apps/codeforafrica/src/lib/data/pagify/index.js b/apps/codeforafrica/src/lib/data/pagify/index.js index 62f8f69dd..074c84300 100644 --- a/apps/codeforafrica/src/lib/data/pagify/index.js +++ b/apps/codeforafrica/src/lib/data/pagify/index.js @@ -1,7 +1,9 @@ +import members from "./members"; import partners from "./partners"; const COLLECTION_BY_SLUG = { partners, + members, }; async function pagify(parentPage, api, context) { diff --git a/apps/codeforafrica/src/lib/data/pagify/members.js b/apps/codeforafrica/src/lib/data/pagify/members.js new file mode 100644 index 000000000..e2bd7ea9f --- /dev/null +++ b/apps/codeforafrica/src/lib/data/pagify/members.js @@ -0,0 +1,37 @@ +import { imageFromMedia } from "@/codeforafrica/lib/data/utils"; + +async function members(api, context) { + const { params, locale } = context; + const slug = params.slugs[2]; + const { docs } = await api.getCollection("members", { + locale, + where: { + slug: { + equals: slug, + }, + }, + }); + if (!docs?.length) { + return null; + } + const [member] = docs; + const meta = { + title: member.name, + description: member.decription, + image: member.image, + }; + return { + blocks: [ + { + relatedProjects: [], + ...member, + user: true, + logo: imageFromMedia(member.image), + blockType: "about-page-entity", + }, + ], + meta, + }; +} + +export default members; diff --git a/apps/codeforafrica/src/lib/data/pagify/partners.js b/apps/codeforafrica/src/lib/data/pagify/partners.js index 9e6797b75..1d7109311 100644 --- a/apps/codeforafrica/src/lib/data/pagify/partners.js +++ b/apps/codeforafrica/src/lib/data/pagify/partners.js @@ -15,15 +15,21 @@ async function partners(api, context) { return null; } const [partner] = docs; + const meta = { + title: partner.name, + description: partner.decription, + image: partner.image, + }; return { blocks: [ { relatedProjects: [], // TODO(koechkevin) Related projects go here once projects implemented ...partner, logo: imageFromMedia(partner.logo), - blockType: "partner", + blockType: "about-page-entity", }, ], + meta, }; } diff --git a/apps/codeforafrica/src/pages/[...slugs].page.js b/apps/codeforafrica/src/pages/[...slugs].page.js index a5d4073f6..a9b772ec2 100644 --- a/apps/codeforafrica/src/pages/[...slugs].page.js +++ b/apps/codeforafrica/src/pages/[...slugs].page.js @@ -1,6 +1,7 @@ import React from "react"; import { SWRConfig } from "swr"; +import AboutPageEntity from "@/codeforafrica/components/AboutPageEntity"; import Articles from "@/codeforafrica/components/Articles"; import ContactForm from "@/codeforafrica/components/ContactForm"; import CustomPageHeader from "@/codeforafrica/components/CustomPageHeader"; @@ -16,10 +17,10 @@ import OurImpact from "@/codeforafrica/components/OurImpact"; import OurPartners from "@/codeforafrica/components/OurPartners"; import OurTeam from "@/codeforafrica/components/OurTeam"; import PageHeader from "@/codeforafrica/components/PageHeader"; -import Partner from "@/codeforafrica/components/Partner"; import { getPageServerSideProps } from "@/codeforafrica/lib/data"; const componentsBySlugs = { + "about-page-entity": AboutPageEntity, articles: Articles, "contact-form": ContactForm, "custom-page-header": CustomPageHeader, @@ -35,7 +36,6 @@ const componentsBySlugs = { "page-header": PageHeader, "our-team": OurTeam, projects: FeaturedProjects, - partner: Partner, }; function Index({ blocks, fallback }) {