From 70504285e821816f390a65b360806b8b14cb4069 Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Fri, 2 Sep 2022 14:37:22 +0300
Subject: [PATCH 01/33] Moved join us to cms
---
apps/codeforafrica/content/pages/contact.md | 13 ++-----
.../src/lib/api.netlify-cms/getContactForm.js | 14 ++++----
apps/codeforafrica/src/lib/index.js | 13 ++++---
.../src/pages/api/admin/config.js | 35 +++----------------
4 files changed, 21 insertions(+), 54 deletions(-)
diff --git a/apps/codeforafrica/content/pages/contact.md b/apps/codeforafrica/content/pages/contact.md
index a85bb2c41..80bdb7d8d 100644
--- a/apps/codeforafrica/content/pages/contact.md
+++ b/apps/codeforafrica/content/pages/contact.md
@@ -61,18 +61,11 @@ contact-form:
join-us:
- icon:
- href: https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform
- src: /images/type-slack-size-64-color-currentcolor.svg
title: We are on Slack!
subtitle: Join us
- action: JOIN OUR SLACK
- offices-addresses:
- - f80da5cc-a72c-4573-abe4-cf0432f1dd87
- - 309d67f8-6bb8-46fd-873f-d0475ddee974
- - 54814d5a-d844-425d-aa3d-f466a2e71afd
- - a57c5c5a-32ab-4e00-a57f-f8b050b58e63
- - 4f079340-a9b1-464a-801a-4edabb67b6e8
+ action:
+ href: https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform
+ label: Join Our Slack
seo:
title: Contact Us
description: Let’s start something together!
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js b/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
index 717771a22..4490510b2 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
@@ -1,13 +1,15 @@
import { getCollectionBySlug } from "./utils";
function getContactForm() {
- const { "contact-form": contactForm } = getCollectionBySlug(
- "content/pages",
- "contact",
- ["contact-form"]
- ).items;
+ const { "contact-form": contactForm, "join-us": joinUs } =
+ getCollectionBySlug("content/pages", "contact", [
+ "contact-form",
+ "join-us",
+ ]).items;
+
const { "embed-code": embedCode } = contactForm || {};
- return { embedCode };
+
+ return { embedCode, joinUs };
}
export default getContactForm;
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 43743529c..ac7e28c0a 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -680,6 +680,10 @@ function getAboutPartnersPageStaticProps() {
function getContactPageStaticProps() {
const seo = getSeo("contact");
+ const { embedCode, joinUs } = getContactForm();
+
+ console.log("joinUs", joinUs);
+
return {
props: {
seo,
@@ -689,17 +693,12 @@ function getContactPageStaticProps() {
...getHero("contact"),
},
{
- ...getContactForm(),
+ embedCode,
slug: "contact-form",
},
{
slug: "join-our-slack",
- title: "We are on Slack!",
- subtitle: "Join us",
- action: {
- label: "Join our Slack",
- href: "https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform",
- },
+ ...joinUs,
},
{
slug: "office-addresses",
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 670cbbdfb..3bcfb8cea 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -621,47 +621,20 @@ module.exports = {
{
label: "Action",
name: "action",
- widget: "string",
- },
- {
- label: "Icon",
- name: "icon",
widget: "object",
fields: [
{
- label: "Src",
- name: "src",
- widget: "image",
- },
- {
- label: "Href",
- name: "href",
- widget: "string",
- },
- {
- label: "Height",
- name: "height",
+ label: "Label",
+ name: "label",
widget: "string",
- required: false,
},
{
- label: "Width",
- name: "width",
+ label: "Link",
+ name: "href",
widget: "string",
- required: false,
},
],
},
- {
- label: "Our Offices",
- name: "offices-addresses",
- widget: "relation",
- collection: "offices-addresses",
- search_fields: ["name"],
- value_field: "id",
- display_fields: ["name"],
- multiple: true,
- },
],
},
{
From 4cd1db30d91b758fa21b9c9de5ea6ae378a9af2f Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Fri, 2 Sep 2022 14:45:23 +0300
Subject: [PATCH 02/33] Removed Console log
---
apps/codeforafrica/src/lib/index.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index ac7e28c0a..096c24ea2 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -682,8 +682,6 @@ function getContactPageStaticProps() {
const { embedCode, joinUs } = getContactForm();
- console.log("joinUs", joinUs);
-
return {
props: {
seo,
From 01edc86250c66def5a6af76c2388265ea7a134aa Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Fri, 2 Sep 2022 14:58:56 +0300
Subject: [PATCH 03/33] Fixed failing test
---
.../src/components/SocialMediaBar/SocialMediaBar.snap.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/apps/codeforafrica/src/components/SocialMediaBar/SocialMediaBar.snap.js b/apps/codeforafrica/src/components/SocialMediaBar/SocialMediaBar.snap.js
index c559d217d..32cfd95f9 100644
--- a/apps/codeforafrica/src/components/SocialMediaBar/SocialMediaBar.snap.js
+++ b/apps/codeforafrica/src/components/SocialMediaBar/SocialMediaBar.snap.js
@@ -6,7 +6,7 @@ exports[` renders unchanged 1`] = `
class="css-mpycnp-MuiStack-root"
>
From b812a214f7ee40cfc2e02f755e1fbf70f01c9773 Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Mon, 5 Sep 2022 16:50:42 +0300
Subject: [PATCH 04/33] Separated joins us from contact
---
.../content/pages/contact-us-join-us.md | 8 ++++++++
apps/codeforafrica/content/pages/contact.md | 6 ------
.../src/lib/api.netlify-cms/getContactForm.js | 14 ++++++--------
.../src/lib/api.netlify-cms/getJoinUs.js | 13 +++++++++++++
.../codeforafrica/src/lib/api.netlify-cms/index.js | 2 ++
apps/codeforafrica/src/lib/index.js | 7 +++----
apps/codeforafrica/src/pages/api/admin/config.js | 14 +++++++++++---
7 files changed, 43 insertions(+), 21 deletions(-)
create mode 100644 apps/codeforafrica/content/pages/contact-us-join-us.md
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
diff --git a/apps/codeforafrica/content/pages/contact-us-join-us.md b/apps/codeforafrica/content/pages/contact-us-join-us.md
new file mode 100644
index 000000000..09dcb7029
--- /dev/null
+++ b/apps/codeforafrica/content/pages/contact-us-join-us.md
@@ -0,0 +1,8 @@
+---
+join-us:
+ title: " We are on Slack!"
+ subtitle: " Join us"
+ action:
+ label: Join Our Slack
+ href: https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform
+---
diff --git a/apps/codeforafrica/content/pages/contact.md b/apps/codeforafrica/content/pages/contact.md
index 80bdb7d8d..22635263e 100644
--- a/apps/codeforafrica/content/pages/contact.md
+++ b/apps/codeforafrica/content/pages/contact.md
@@ -60,12 +60,6 @@ contact-form:
-join-us:
- title: We are on Slack!
- subtitle: Join us
- action:
- href: https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform
- label: Join Our Slack
seo:
title: Contact Us
description: Let’s start something together!
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js b/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
index 4490510b2..717771a22 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
@@ -1,15 +1,13 @@
import { getCollectionBySlug } from "./utils";
function getContactForm() {
- const { "contact-form": contactForm, "join-us": joinUs } =
- getCollectionBySlug("content/pages", "contact", [
- "contact-form",
- "join-us",
- ]).items;
-
+ const { "contact-form": contactForm } = getCollectionBySlug(
+ "content/pages",
+ "contact",
+ ["contact-form"]
+ ).items;
const { "embed-code": embedCode } = contactForm || {};
-
- return { embedCode, joinUs };
+ return { embedCode };
}
export default getContactForm;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
new file mode 100644
index 000000000..964a3cbfd
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
@@ -0,0 +1,13 @@
+import { getCollectionBySlug } from "./utils";
+
+function getJoinUs() {
+ const { "join-us": joinUs } = getCollectionBySlug(
+ "content/pages",
+ "contact-us-join-us",
+ ["join-us"]
+ ).data;
+
+ return joinUs;
+}
+
+export default getJoinUs;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index bc259028e..9bb6f797c 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -1,6 +1,7 @@
import getBody from "./getBody";
import getContactForm from "./getContactForm";
import getGetInTouch from "./getGetInTouch";
+import getJoinUs from "./getJoinUs";
import getNewsAndStories from "./getNewsAndStories";
import getOffices from "./getOffices";
import getOurGuidingPrinciples from "./getOurGuidingPrinciples";
@@ -36,4 +37,5 @@ export {
getOurTeam,
getPartners,
getTeam,
+ getJoinUs,
};
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 096c24ea2..92c30820c 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -18,6 +18,7 @@ import {
getPartners,
getTeam,
getSeo,
+ getJoinUs,
} from "./api.netlify-cms";
import {
@@ -680,8 +681,6 @@ function getAboutPartnersPageStaticProps() {
function getContactPageStaticProps() {
const seo = getSeo("contact");
- const { embedCode, joinUs } = getContactForm();
-
return {
props: {
seo,
@@ -691,12 +690,12 @@ function getContactPageStaticProps() {
...getHero("contact"),
},
{
- embedCode,
+ ...getContactForm(),
slug: "contact-form",
},
{
slug: "join-our-slack",
- ...joinUs,
+ ...getJoinUs(),
},
{
slug: "office-addresses",
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 71aa865b9..347590ab3 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -603,6 +603,17 @@ module.exports = {
},
],
},
+ {
+ ...seoFields,
+ },
+ ],
+ },
+ {
+ label: "Contact Us | Join Us",
+ name: "contact-us-join-us",
+ file: `${APP_DIRECTORY}content/pages/contact-us-join-us.md`,
+ widget: "object",
+ fields: [
{
label: "Join Us",
name: "join-us",
@@ -637,9 +648,6 @@ module.exports = {
},
],
},
- {
- ...seoFields,
- },
],
},
{
From acec6d047cf5ae0ef601ee409f4648e618da55b8 Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Tue, 6 Sep 2022 08:02:28 +0300
Subject: [PATCH 05/33] Moved hero slug to netlify
---
.../codeforafrica/src/lib/api.netlify-cms/index.js | 2 +-
.../src/lib/api.netlify-cms/sections/getHero.js | 1 +
apps/codeforafrica/src/lib/index.js | 14 +-------------
3 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index 9bb6f797c..f0b708c3c 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -26,6 +26,7 @@ export {
getHeader,
getHero,
getGetInTouch,
+ getJoinUs,
getMeetOurTeam,
getNewsAndStories,
getOffices,
@@ -37,5 +38,4 @@ export {
getOurTeam,
getPartners,
getTeam,
- getJoinUs,
};
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
index 8d97f7c1f..6a7e77fb6 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
@@ -9,6 +9,7 @@ const indexPageDir = join(process.cwd(), "content/pages");
export default function getHero(page, fields = ["hero"]) {
const { hero } = getCollectionBySlug(indexPageDir, page, fields).items;
hero.title = marked.parseInline(hero.title);
+ hero.slug = "hero";
return hero;
}
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 92c30820c..827352ca2 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -7,6 +7,7 @@ import {
getGetInTouch,
getHeader,
getHero,
+ getJoinUs,
getMeetOurTeam,
getNewsAndStories,
getOffices,
@@ -18,7 +19,6 @@ import {
getPartners,
getTeam,
getSeo,
- getJoinUs,
} from "./api.netlify-cms";
import {
@@ -168,7 +168,6 @@ async function getHomePageStaticProps() {
sections: [
{
...getHero("index"),
- slug: "hero",
},
{
slug: "projects",
@@ -243,7 +242,6 @@ async function getOpportunitiesPageStaticProps() {
seo,
sections: [
{
- slug: "hero",
...getHero("opportunities"),
},
{
@@ -289,7 +287,6 @@ function getImprintPageStaticProps() {
sections: [
{
...getHero("imprint"),
- slug: "hero",
},
],
footer,
@@ -309,7 +306,6 @@ function getPrivacyPageStaticProps() {
sections: [
{
...getHero("privacy-policy"),
- slug: "hero",
},
],
footer,
@@ -372,7 +368,6 @@ function getProjectsPageStaticProps() {
seo,
sections: [
{
- slug: "hero",
...getHero("our-work"),
},
{
@@ -492,7 +487,6 @@ function getAboutImpactPageStaticProps() {
sections: [
{
...getHero("about"),
- slug: "hero",
},
{
slug: "our-impact",
@@ -550,7 +544,6 @@ function getAboutMembersPageStaticProps() {
sections: [
{
...getHero("about"),
- slug: "hero",
},
{
...getOurTeam(),
@@ -580,7 +573,6 @@ function getAboutPageStaticProps() {
sections: [
{
...getHero("about"),
- slug: "hero",
},
{
...getOurMission(),
@@ -660,7 +652,6 @@ function getAboutPartnersPageStaticProps() {
sections: [
{
...getHero("about"),
- slug: "hero",
},
{
slug: "our-partners",
@@ -686,7 +677,6 @@ function getContactPageStaticProps() {
seo,
sections: [
{
- slug: "hero",
...getHero("contact"),
},
{
@@ -736,7 +726,6 @@ async function getErrorPageStaticProps() {
sections: [
{
...getHero("error"),
- slug: "hero",
},
{
...(await getProcessedRecentStories("error")),
@@ -759,7 +748,6 @@ async function get404PageStaticProps() {
sections: [
{
...getHero("404"),
- slug: "hero",
},
{
...(await getProcessedRecentStories("404")),
From 597f811def226d39e8f3a9f89baa641fe42e4ba2 Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Tue, 6 Sep 2022 08:04:28 +0300
Subject: [PATCH 06/33] moved impact slug to netlify
---
apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js | 2 +-
apps/codeforafrica/src/lib/index.js | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
index 3e414be01..6942a4b78 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
@@ -13,5 +13,5 @@ export default function geOurImpact(page = "index") {
// Need to maintain order of how impact were selected in ourImpact
const list = impactIds?.map((id) => impact.find((i) => i.id === id)) ?? null;
- return { action, list, title };
+ return { action, list, title, slug: "our-impact" };
}
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 827352ca2..686f6c0dd 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -185,7 +185,6 @@ async function getHomePageStaticProps() {
},
{
...getOurImpact(),
- slug: "our-impact",
},
],
footer,
@@ -489,7 +488,6 @@ function getAboutImpactPageStaticProps() {
...getHero("about"),
},
{
- slug: "our-impact",
...getOurImpact("about"),
},
{
@@ -595,7 +593,6 @@ function getAboutPageStaticProps() {
},
{
...getOurImpact("about"),
- slug: "our-impact",
},
{
...getGetInTouch(),
From d860dff4bc26e0bc4566e6df2918d810df1dead6 Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Tue, 6 Sep 2022 08:11:20 +0300
Subject: [PATCH 07/33] Moved get in touch slug to netlify
---
.../src/lib/api.netlify-cms/getGetInTouch.js | 8 +++++---
apps/codeforafrica/src/lib/index.js | 4 ----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js b/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
index 550a2da05..06382c5f0 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
@@ -1,7 +1,9 @@
import { getCollectionBySlug } from "./utils";
export default function getGetInTouch() {
- return getCollectionBySlug("content/pages", "about", ["get-in-touch"]).items[
- "get-in-touch"
- ];
+ const getInTouch = getCollectionBySlug("content/pages", "about", [
+ "get-in-touch",
+ ]).items["get-in-touch"];
+
+ return { ...getInTouch, slug: "get-in-touch" };
}
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 686f6c0dd..7df648b9c 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -492,7 +492,6 @@ function getAboutImpactPageStaticProps() {
},
{
...getGetInTouch(),
- slug: "get-in-touch",
},
],
footer,
@@ -552,7 +551,6 @@ function getAboutMembersPageStaticProps() {
},
{
...getGetInTouch(),
- slug: "get-in-touch",
},
],
footer,
@@ -596,7 +594,6 @@ function getAboutPageStaticProps() {
},
{
...getGetInTouch(),
- slug: "get-in-touch",
},
],
footer,
@@ -656,7 +653,6 @@ function getAboutPartnersPageStaticProps() {
},
{
...getGetInTouch(),
- slug: "get-in-touch",
},
],
footer,
From fd6a409d82f82149b63268aded90d00a17b0e77f Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Tue, 6 Sep 2022 08:17:35 +0300
Subject: [PATCH 08/33] moved meet our team slug to netlify
---
.../src/lib/api.netlify-cms/sections/getMeetOurTeam.js | 1 +
apps/codeforafrica/src/lib/index.js | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js
index 5d3669d09..f47f487dc 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js
@@ -15,5 +15,6 @@ export default function getMeetOurTeam(
];
meetOurTeam.logo = meetOurTeam.image?.src;
meetOurTeam.description = marked(meetOurTeam.description);
+ meetOurTeam.slug = "meet-our-team";
return meetOurTeam;
}
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 7df648b9c..0e6fc318b 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -174,7 +174,7 @@ async function getHomePageStaticProps() {
projects,
tags: getProjectTags({ includeAll: false }),
},
- { ...meetOurTeam, slug: "meet-our-team" },
+ { ...meetOurTeam },
{
...(await getProcessedNewsAndStories()),
slug: "news-stories",
From e9b9ec1ee66eb3a8385857286a1f08798db042cf Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Tue, 6 Sep 2022 08:35:05 +0300
Subject: [PATCH 09/33] refractored some slugs and titles
---
.../src/lib/api.netlify-cms/getJoinUs.js | 2 +-
.../lib/api.netlify-cms/getOurGuidingPrinciples.js | 2 +-
.../src/lib/api.netlify-cms/getOurMission.js | 1 +
.../src/lib/api.netlify-cms/getOurTeam.js | 2 +-
apps/codeforafrica/src/lib/index.js | 12 ++----------
5 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
index 964a3cbfd..5dc926635 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
@@ -7,7 +7,7 @@ function getJoinUs() {
["join-us"]
).data;
- return joinUs;
+ return { ...joinUs, slug: "join-our-slack" };
}
export default getJoinUs;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
index d134cf04e..65e570a47 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
@@ -20,7 +20,7 @@ function getOurGuidingPrinciples() {
const list =
principleIds?.map((id) => allPrinciples.find((p) => p.id === id)) ?? null;
- return { title, list };
+ return { title, list, slug: "guiding-principles" };
}
export default getOurGuidingPrinciples;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
index 71221aa3e..31328228a 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
@@ -11,6 +11,7 @@ export default function getOurMission() {
"our-mission",
]).items;
ourMission.description = marked(ourMission.description);
+ ourMission.slug = "our-mission";
return ourMission;
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js
index dd557e40b..979b007c6 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js
@@ -5,5 +5,5 @@ export default function geOurPartners() {
"our-team": { title },
} = getCollectionBySlug("content/pages", "about", ["our-team"]).items;
- return { title };
+ return { title, slug: "our-team" };
}
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 0e6fc318b..7c000e4dd 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -157,7 +157,7 @@ async function getProcessedNewsAndStories() {
const allStories = await getAllStories();
const articles = prioritiseFeaturedStory(allStories).slice(0, count);
- return { title, articles };
+ return { title, articles, slug: "news-stories" };
}
async function getHomePageStaticProps() {
@@ -177,7 +177,6 @@ async function getHomePageStaticProps() {
{ ...meetOurTeam },
{
...(await getProcessedNewsAndStories()),
- slug: "news-stories",
},
{
slug: "our-partners",
@@ -547,7 +546,6 @@ function getAboutMembersPageStaticProps() {
pathname: "/about/members",
tags: getMembersFieldTags(),
team: getMembers(),
- slug: "our-team",
},
{
...getGetInTouch(),
@@ -572,18 +570,15 @@ function getAboutPageStaticProps() {
},
{
...getOurMission(),
- slug: "our-mission",
},
{
...getOurGuidingPrinciples(),
- slug: "guiding-principles",
},
{
...getOurTeam(),
tags: getMembersFieldTags(),
team: getMembers(),
- slug: "our-team",
},
{
slug: "our-partners",
@@ -677,7 +672,6 @@ function getContactPageStaticProps() {
slug: "contact-form",
},
{
- slug: "join-our-slack",
...getJoinUs(),
},
{
@@ -707,7 +701,7 @@ async function getProcessedRecentStories(page) {
const allStories = await getAllStories();
const { title, count = 3 } = getNewsAndStories(page);
const articles = allStories.slice(0, count);
- return { title, articles };
+ return { title, articles, slug: "news-stories" };
}
async function getErrorPageStaticProps() {
@@ -722,7 +716,6 @@ async function getErrorPageStaticProps() {
},
{
...(await getProcessedRecentStories("error")),
- slug: "news-stories",
},
],
footer,
@@ -744,7 +737,6 @@ async function get404PageStaticProps() {
},
{
...(await getProcessedRecentStories("404")),
- slug: "news-stories",
title: "Recent Stories",
},
],
From 504f28c405c70ab66a2951e2504db51d072065c4 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Thu, 8 Sep 2022 11:02:54 +0300
Subject: [PATCH 10/33] Handle slug for file-based collections
Update get-in-touch as test case
---
.../src/lib/api.netlify-cms/getGetInTouch.js | 7 ++-----
apps/codeforafrica/src/lib/api.netlify-cms/utils.js | 11 ++++++++++-
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js b/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
index 06382c5f0..44fd9e6cb 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
@@ -1,9 +1,6 @@
import { getCollectionBySlug } from "./utils";
export default function getGetInTouch() {
- const getInTouch = getCollectionBySlug("content/pages", "about", [
- "get-in-touch",
- ]).items["get-in-touch"];
-
- return { ...getInTouch, slug: "get-in-touch" };
+ return getCollectionBySlug("content/pages", "about", ["get-in-touch", "slug"])
+ .items["get-in-touch"];
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/utils.js b/apps/codeforafrica/src/lib/api.netlify-cms/utils.js
index cc20ed6f4..c2e669cb9 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/utils.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/utils.js
@@ -25,7 +25,16 @@ export function getCollectionBySlug(collectionDir, slug, fields) {
} else if (curr === "slug") {
acc.slug = realSlug;
} else {
- acc[curr] = data[curr] || null;
+ // The slug field above works for folder-based collections e.g. impact
+ // but not for file-based collections e.g. get-in-touch in about.
+ // Since field names are guaranteed to be unique (in page) and are set
+ // in config, we can set the slug to be field name in file-based
+ // collections
+ let currData = data[curr] || null;
+ if (currData?.constructor === Object && fields.includes("slug")) {
+ currData = { slug: curr, ...currData };
+ }
+ acc[curr] = currData;
}
return acc;
}, {});
From 827c84ad9d177e035f15c933f6efc7ec9c09034e Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Fri, 9 Sep 2022 01:36:38 +0300
Subject: [PATCH 11/33] Partially fixed hard coded slug
---
.../lib/api.netlify-cms/getOurGuidingPrinciples.js | 13 +++++++------
.../src/lib/api.netlify-cms/getOurImpact.js | 11 ++++++++---
.../src/lib/api.netlify-cms/getOurMission.js | 2 +-
.../src/lib/api.netlify-cms/getOurTeam.js | 6 +++---
.../src/lib/api.netlify-cms/sections/getHero.js | 3 +--
.../lib/api.netlify-cms/sections/getMeetOurTeam.js | 3 +--
6 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
index 65e570a47..91edd9280 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
@@ -6,11 +6,12 @@ import { getCollectionBySlug } from "./utils";
const pagesDir = join(process.cwd(), "content/pages");
function getOurGuidingPrinciples() {
- const { title, "guiding-principle-list": principleIds } = getCollectionBySlug(
- pagesDir,
- "about",
- ["guiding-principles"]
- ).items["guiding-principles"];
+ const {
+ title,
+ "guiding-principle-list": principleIds,
+ slug,
+ } = getCollectionBySlug(pagesDir, "about", ["guiding-principles", "slug"])
+ .items["guiding-principles"];
const allPrinciples = getGuidingPrinciples([
"id",
"title",
@@ -20,7 +21,7 @@ function getOurGuidingPrinciples() {
const list =
principleIds?.map((id) => allPrinciples.find((p) => p.id === id)) ?? null;
- return { title, list, slug: "guiding-principles" };
+ return { title, list, slug };
}
export default getOurGuidingPrinciples;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
index 6942a4b78..5fc9e49dd 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
@@ -7,11 +7,16 @@ const pageDir = join(process.cwd(), "content/pages");
export default function geOurImpact(page = "index") {
const {
- "our-impact": { action = null, "impact-list": impactIds, title = null },
- } = getCollectionBySlug(pageDir, page, ["our-impact"]).items;
+ "our-impact": {
+ action = null,
+ "impact-list": impactIds,
+ title = null,
+ slug = null,
+ },
+ } = getCollectionBySlug(pageDir, page, ["our-impact", "slug"]).items;
const impact = getImpactList();
// Need to maintain order of how impact were selected in ourImpact
const list = impactIds?.map((id) => impact.find((i) => i.id === id)) ?? null;
- return { action, list, title, slug: "our-impact" };
+ return { action, list, title, slug };
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
index 31328228a..81196da3e 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
@@ -9,9 +9,9 @@ const pagesDir = join(process.cwd(), "content/pages");
export default function getOurMission() {
const { "our-mission": ourMission } = getCollectionBySlug(pagesDir, "about", [
"our-mission",
+ "slug",
]).items;
ourMission.description = marked(ourMission.description);
- ourMission.slug = "our-mission";
return ourMission;
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js
index 979b007c6..950473562 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurTeam.js
@@ -2,8 +2,8 @@ import { getCollectionBySlug } from "./utils";
export default function geOurPartners() {
const {
- "our-team": { title },
- } = getCollectionBySlug("content/pages", "about", ["our-team"]).items;
+ "our-team": { title, slug },
+ } = getCollectionBySlug("content/pages", "about", ["our-team", "slug"]).items;
- return { title, slug: "our-team" };
+ return { title, slug };
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
index 6a7e77fb6..f38a4212c 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
@@ -6,10 +6,9 @@ import { getCollectionBySlug } from "../utils";
const indexPageDir = join(process.cwd(), "content/pages");
-export default function getHero(page, fields = ["hero"]) {
+export default function getHero(page, fields = ["hero", "slug"]) {
const { hero } = getCollectionBySlug(indexPageDir, page, fields).items;
hero.title = marked.parseInline(hero.title);
- hero.slug = "hero";
return hero;
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js
index f47f487dc..25ffc9e21 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getMeetOurTeam.js
@@ -8,13 +8,12 @@ const indexPageDir = join(process.cwd(), "content/pages");
export default function getMeetOurTeam(
page = "index",
- fields = ["meet-our-team"]
+ fields = ["meet-our-team", "slug"]
) {
const meetOurTeam = getCollectionBySlug(indexPageDir, page, fields).items[
"meet-our-team"
];
meetOurTeam.logo = meetOurTeam.image?.src;
meetOurTeam.description = marked(meetOurTeam.description);
- meetOurTeam.slug = "meet-our-team";
return meetOurTeam;
}
From 234308d8667806576aec72b1dc26fa71e6b487bb Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Fri, 9 Sep 2022 02:01:20 +0300
Subject: [PATCH 12/33] Get news-stories slug from cms
---
.../src/lib/api.netlify-cms/getNewsAndStories.js | 14 ++++++++------
apps/codeforafrica/src/lib/index.js | 8 ++++----
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getNewsAndStories.js b/apps/codeforafrica/src/lib/api.netlify-cms/getNewsAndStories.js
index b8891364b..147f6f33a 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getNewsAndStories.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getNewsAndStories.js
@@ -3,13 +3,15 @@ import { getCollectionBySlug } from "./utils";
const FIELD_NAME = "news-stories";
function getNewsAndStories(page) {
- const { "articles-count": count, title } = getCollectionBySlug(
- "content/pages",
- page,
- [FIELD_NAME]
- ).items[FIELD_NAME];
+ const {
+ "articles-count": count,
+ title,
+ slug,
+ } = getCollectionBySlug("content/pages", page, [FIELD_NAME, "slug"]).items[
+ FIELD_NAME
+ ];
- return { count, title };
+ return { count, title, slug };
}
export default getNewsAndStories;
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 7c000e4dd..80563cd2f 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -153,11 +153,11 @@ export async function getStories(options) {
}
async function getProcessedNewsAndStories() {
- const { title, count = 4 } = getNewsAndStories("index");
+ const { title, count = 4, slug } = getNewsAndStories("index");
const allStories = await getAllStories();
const articles = prioritiseFeaturedStory(allStories).slice(0, count);
- return { title, articles, slug: "news-stories" };
+ return { title, articles, slug };
}
async function getHomePageStaticProps() {
@@ -699,9 +699,9 @@ function getContactPageStaticProps() {
async function getProcessedRecentStories(page) {
const allStories = await getAllStories();
- const { title, count = 3 } = getNewsAndStories(page);
+ const { title, count = 3, slug } = getNewsAndStories(page);
const articles = allStories.slice(0, count);
- return { title, articles, slug: "news-stories" };
+ return { title, articles, slug };
}
async function getErrorPageStaticProps() {
From 238c9b99104405a2e55ba335717d7773f9b7be10 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 10:51:15 +0300
Subject: [PATCH 13/33] Pull slug + restructure to match component props
---
apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js
index 6ff2359ba..a74b8fbf5 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js
@@ -10,11 +10,12 @@ const pageDir = join(process.cwd(), "content/pages");
export default function geOurPartners(page = "index") {
const {
"our-partners": {
+ slug,
title: originalTitle,
"partners-list": partnersIds,
action = null,
},
- } = getCollectionBySlug(pageDir, page, ["our-partners"]).items;
+ } = getCollectionBySlug(pageDir, page, ["our-partners", "slug"]).items;
const title = marked.parseInline(originalTitle);
const allPartners = getPartners([
"id",
@@ -31,5 +32,5 @@ export default function geOurPartners(page = "index") {
? partnersIds?.map((id) => allPartners.find((p) => p.id === id)) ?? null
: allPartners;
- return { title, list, action };
+ return { slug, partners: { title, list, action } };
}
From a6b356033c60e0f3aad98bec4d3cadb5264e4db0 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 10:51:48 +0300
Subject: [PATCH 14/33] Remove hard-coded our-partners
---
apps/codeforafrica/src/lib/index.js | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 80563cd2f..00f6d48b6 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -179,8 +179,7 @@ async function getHomePageStaticProps() {
...(await getProcessedNewsAndStories()),
},
{
- slug: "our-partners",
- partners: getOurPartners(),
+ ...getOurPartners(),
},
{
...getOurImpact(),
@@ -581,8 +580,7 @@ function getAboutPageStaticProps() {
team: getMembers(),
},
{
- slug: "our-partners",
- partners: getOurPartners("about"),
+ ...getOurPartners("about"),
},
{
...getOurImpact("about"),
@@ -643,8 +641,7 @@ function getAboutPartnersPageStaticProps() {
...getHero("about"),
},
{
- slug: "our-partners",
- partners: getOurPartners("about"),
+ ...getOurPartners("about"),
},
{
...getGetInTouch(),
From b299bed59e8d9a760cbabb5dfa53ccbb1145cf18 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:05:26 +0300
Subject: [PATCH 15/33] Add related project config and content to individual
partner page
---
.../content/pages/about-partners-individual.md | 2 ++
apps/codeforafrica/src/pages/api/admin/config.js | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/apps/codeforafrica/content/pages/about-partners-individual.md b/apps/codeforafrica/content/pages/about-partners-individual.md
index e96d8439d..b2457041a 100644
--- a/apps/codeforafrica/content/pages/about-partners-individual.md
+++ b/apps/codeforafrica/content/pages/about-partners-individual.md
@@ -1,4 +1,6 @@
---
+related-projects:
+ title: Related Projects
seo:
title-template: "%s | Partners | About | Code for Africa"
---
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 347590ab3..c35888262 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -561,6 +561,18 @@ module.exports = {
name: "about-partners-individual",
file: `${APP_DIRECTORY}content/pages/about-partners-individual.md`,
fields: [
+ {
+ label: "Related Projects",
+ name: "related-projects",
+ widget: "object",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
From d0e7871fc5622f9ac1220c34123b40026e8b68ab Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:05:56 +0300
Subject: [PATCH 16/33] Pull related projects from CMS
---
.../src/lib/api.netlify-cms/getRelatedProjects.js | 11 +++++++++++
apps/codeforafrica/src/lib/api.netlify-cms/index.js | 2 ++
apps/codeforafrica/src/lib/index.js | 11 +++++++----
3 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getRelatedProjects.js
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getRelatedProjects.js b/apps/codeforafrica/src/lib/api.netlify-cms/getRelatedProjects.js
new file mode 100644
index 000000000..9a6cffb57
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getRelatedProjects.js
@@ -0,0 +1,11 @@
+import { getCollectionBySlug } from "./utils";
+
+const FIELD_NAME = "related-projects";
+
+function getRelatedProjects(page) {
+ return getCollectionBySlug("content/pages", page, [FIELD_NAME, "slug"]).items[
+ FIELD_NAME
+ ];
+}
+
+export default getRelatedProjects;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index f0b708c3c..99a44f635 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -11,6 +11,7 @@ import getOurPartners from "./getOurPartners";
import getOurTeam from "./getOurTeam";
import getPartners from "./getPartners";
import getCmsProjects from "./getProjects";
+import getRelatedProjects from "./getRelatedProjects";
import getTeam from "./getTeam";
import getFooter from "./sections/getFooter";
import getHeader from "./sections/getHeader";
@@ -35,6 +36,7 @@ export {
getOurMission,
getOurPartners,
getSeo,
+ getRelatedProjects,
getOurTeam,
getPartners,
getTeam,
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 00f6d48b6..cb45a2801 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -17,6 +17,7 @@ import {
getOurPartners,
getOurTeam,
getPartners,
+ getRelatedProjects,
getTeam,
getSeo,
} from "./api.netlify-cms";
@@ -602,11 +603,14 @@ function getAboutPartnerPageStaticProps(params) {
);
if (partner) {
+ const relatedProjects = getRelatedProjects("about-partners-individual");
const seo = getSeo("about-partners-individual", {
title: partner.name,
// TODO(kilemens): Add short description to each partner
});
- const startIndex = getRandomInt(projects.length - 3);
+ const partnerProjects = projects.filter((p) =>
+ p.partners?.list?.some((l) => equalsIgnoreCase(l.name, partner.name))
+ );
return {
props: {
@@ -614,9 +618,8 @@ function getAboutPartnerPageStaticProps(params) {
partner: { ...partner, image: partner.logo, title: "Partner" },
sections: [
{
- slug: "related-projects",
- title: "Projects",
- projects: projects.slice(startIndex, startIndex + 3),
+ ...relatedProjects,
+ projects: partnerProjects,
},
],
footer,
From 1bdb570c52d7a795ddfbcf957222a613f48d72cc Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:24:06 +0300
Subject: [PATCH 17/33] Add related project config to our-work-individual
---
.../content/pages/our-work-individual.md | 2 ++
apps/codeforafrica/src/pages/api/admin/config.js | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/apps/codeforafrica/content/pages/our-work-individual.md b/apps/codeforafrica/content/pages/our-work-individual.md
index e5d9e43a5..850c8658c 100644
--- a/apps/codeforafrica/content/pages/our-work-individual.md
+++ b/apps/codeforafrica/content/pages/our-work-individual.md
@@ -1,4 +1,6 @@
---
+related-projects:
+ title: Explore other projects
seo:
title-template: "%s | Our Work | Code for Africa"
---
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index c35888262..ef82c3ce5 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -694,6 +694,18 @@ module.exports = {
name: "our-work-individual",
file: `${APP_DIRECTORY}content/pages/our-work-individual.md`,
fields: [
+ {
+ label: "Related Projects",
+ name: "related-projects",
+ widget: "object",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
From 8eb034707856e0d375b85543f9ba6281e188c7f4 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:25:57 +0300
Subject: [PATCH 18/33] Pull our-work-individual's related-projects from CMS
---
apps/codeforafrica/src/lib/index.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index cb45a2801..1042b88e5 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -65,6 +65,11 @@ function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
+function getRandomStartIndex(length, size) {
+ const max = length >= size ? length - size : length;
+ return getRandomInt(max);
+}
+
const navbar = getHeader();
const footer = getFooter();
@@ -320,12 +325,15 @@ async function getProjectPageStaticProps(params) {
if (project) {
const relatedStories = await getRelatedStoriesByTags([project.name]);
+ const relatedProjects = getRelatedProjects("our-work-individual");
const seo = getSeo("our-work-individual", {
title: project.name,
description:
// subtitle could contain html content
project.subtitle.replace(/<[^>]*>/g, "").trim() || project.title,
});
+ const startIndex = getRandomStartIndex(projects.length, 3);
+
return {
props: {
seo,
@@ -342,11 +350,10 @@ async function getProjectPageStaticProps(params) {
articles: relatedStories.slice(0, 3),
},
{
- slug: "related-projects",
- title: "Explore other projects",
+ ...relatedProjects,
projects: projects
.filter((p) => p.slug !== project.slug)
- .slice(0, 3),
+ .slice(startIndex, startIndex + 3),
},
],
footer,
@@ -355,7 +362,6 @@ async function getProjectPageStaticProps(params) {
revalidate: DEFAULT_REVALIDATE,
};
}
-
return { notFound: true };
}
From fda66c669099d27d6365ff8a21b6e4e4545268b7 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:33:54 +0300
Subject: [PATCH 19/33] add related-project to about-members-individual config
---
.../content/pages/about-members-individual.md | 2 ++
apps/codeforafrica/src/pages/api/admin/config.js | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/apps/codeforafrica/content/pages/about-members-individual.md b/apps/codeforafrica/content/pages/about-members-individual.md
index b78c29628..c4215da12 100644
--- a/apps/codeforafrica/content/pages/about-members-individual.md
+++ b/apps/codeforafrica/content/pages/about-members-individual.md
@@ -1,4 +1,6 @@
---
+related-projects:
+ title: Projects
seo:
title-template: "%s | Members | About | Code for Africa"
---
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index ef82c3ce5..320a0a5ed 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -541,6 +541,18 @@ module.exports = {
name: "about-members-individual",
file: `${APP_DIRECTORY}content/pages/about-members-individual.md`,
fields: [
+ {
+ label: "Related Projects",
+ name: "related-projects",
+ widget: "object",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
From b033d4eb72fa88aa86dce56c131a9c868607e518 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:34:39 +0300
Subject: [PATCH 20/33] pull about-members-individual's related-projects from
CMS
---
apps/codeforafrica/src/lib/index.js | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 1042b88e5..2f53fc5ad 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -510,20 +510,22 @@ function getAboutMemberPageStaticProps(params) {
const member = team.find(({ href }) => equalsIgnoreCase(href, params?.slug));
if (member) {
+ const relatedProjects = getRelatedProjects("about-members-individual");
const seo = getSeo("about-members-individual", {
title: member.name,
description: member.title,
});
- const startIndex = getRandomInt(projects.length - 3);
+
return {
props: {
seo,
member,
sections: [
{
- slug: "related-projects",
- title: "Projects",
- projects: projects.slice(startIndex, startIndex + 3),
+ ...relatedProjects,
+ projects: projects.filter((p) =>
+ p.team?.list?.find((m) => m.id === member.id)
+ ),
},
],
footer,
From a430c47f0b586b89ee5076faa383fdbf6b9a5cad Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 11:38:29 +0300
Subject: [PATCH 21/33] Use id for matching instead of name
---
apps/codeforafrica/src/lib/index.js | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 2f53fc5ad..fcee9f806 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -616,9 +616,6 @@ function getAboutPartnerPageStaticProps(params) {
title: partner.name,
// TODO(kilemens): Add short description to each partner
});
- const partnerProjects = projects.filter((p) =>
- p.partners?.list?.some((l) => equalsIgnoreCase(l.name, partner.name))
- );
return {
props: {
@@ -627,7 +624,9 @@ function getAboutPartnerPageStaticProps(params) {
sections: [
{
...relatedProjects,
- projects: partnerProjects,
+ projects: projects.filter((p) =>
+ p.partners?.list?.find((l) => l.id === partner.id)
+ ),
},
],
footer,
From 652f54bb067a0e2858b4c2b303e399b29a55a7ba Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:01:53 +0300
Subject: [PATCH 22/33] Add our-projects to index page
---
apps/codeforafrica/content/pages/index.md | 8 ++------
.../src/pages/api/admin/config.js | 19 +++++++++++--------
2 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/apps/codeforafrica/content/pages/index.md b/apps/codeforafrica/content/pages/index.md
index 37f3ac8d2..e32164b03 100644
--- a/apps/codeforafrica/content/pages/index.md
+++ b/apps/codeforafrica/content/pages/index.md
@@ -10,12 +10,8 @@ hero:
to accelerate change through data-driven initiatives.
image:
src: /images/group-4429.png
-projects:
- - 14fdf60f-2928-4776-b208-6641e8413f74
- - 7e3a1ef1-576d-4428-824d-a12fa774519d
- - afcfdec9-99d7-4f2c-8bdb-964159c0676d
- - 07f3259e-2379-4850-83b8-85cacde0fcb8
- - 31626677-0bc8-49cb-a2e6-1d7e5504d1fe
+our-projects:
+ title: Projects
meet-our-team:
title: Our pan-African team is spread across the continent
description: >-
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 320a0a5ed..7c54d03d6 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -188,14 +188,17 @@ module.exports = {
],
},
{
- label: "Projects",
- name: "projects",
- widget: "relation",
- collection: "projects",
- search_fields: ["name"],
- value_field: "id",
- display_fields: ["name"],
- multiple: true,
+ label: "Our Projects",
+ name: "our-projects",
+ widget: "object",
+ collapsed: true,
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
},
{
label: "Meet Our Team",
From e214ae86266e3a494006566131690096fe11287b Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:02:22 +0300
Subject: [PATCH 23/33] Add ability to pull our-projects to CMS
---
.../src/lib/api.netlify-cms/getOurProjects.js | 11 +++++++++++
apps/codeforafrica/src/lib/api.netlify-cms/index.js | 2 ++
2 files changed, 13 insertions(+)
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js
new file mode 100644
index 000000000..2911aad96
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js
@@ -0,0 +1,11 @@
+import { getCollectionBySlug } from "./utils";
+
+const FIELD_NAME = "our-project";
+export default function geOurProjects() {
+ const { slug } = getCollectionBySlug("content/pages", "index", [
+ FIELD_NAME,
+ "slug",
+ ]).items[FIELD_NAME];
+
+ return { slug };
+}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index 99a44f635..1992cb7a4 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -8,6 +8,7 @@ import getOurGuidingPrinciples from "./getOurGuidingPrinciples";
import getOurImpact from "./getOurImpact";
import getOurMission from "./getOurMission";
import getOurPartners from "./getOurPartners";
+import getOurProjects from "./getOurProjects";
import getOurTeam from "./getOurTeam";
import getPartners from "./getPartners";
import getCmsProjects from "./getProjects";
@@ -35,6 +36,7 @@ export {
getOurImpact,
getOurMission,
getOurPartners,
+ getOurProjects,
getSeo,
getRelatedProjects,
getOurTeam,
From 95021f054e6109d0c6261bf068d2c06cdde307a6 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:02:45 +0300
Subject: [PATCH 24/33] Pull index's our-projects from CMS
---
apps/codeforafrica/src/lib/index.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index fcee9f806..0fb3a0cda 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -15,6 +15,7 @@ import {
getOurImpact,
getOurMission,
getOurPartners,
+ getOurProjects,
getOurTeam,
getPartners,
getRelatedProjects,
@@ -176,7 +177,7 @@ async function getHomePageStaticProps() {
...getHero("index"),
},
{
- slug: "projects",
+ ...getOurProjects(),
projects,
tags: getProjectTags({ includeAll: false }),
},
@@ -744,7 +745,6 @@ async function get404PageStaticProps() {
},
{
...(await getProcessedRecentStories("404")),
- title: "Recent Stories",
},
],
footer,
From d865067b91485f1425e8a030309a8441eb956c8a Mon Sep 17 00:00:00 2001
From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com>
Date: Fri, 9 Sep 2022 12:02:50 +0300
Subject: [PATCH 25/33] Fixed Join Us
---
.../content/pages/contact-us-join-us.md | 8 --------
apps/codeforafrica/content/pages/contact.md | 6 ++++++
.../src/lib/api.netlify-cms/getJoinUs.js | 11 ++++-------
apps/codeforafrica/src/pages/api/admin/config.js | 16 ++++------------
4 files changed, 14 insertions(+), 27 deletions(-)
delete mode 100644 apps/codeforafrica/content/pages/contact-us-join-us.md
diff --git a/apps/codeforafrica/content/pages/contact-us-join-us.md b/apps/codeforafrica/content/pages/contact-us-join-us.md
deleted file mode 100644
index 09dcb7029..000000000
--- a/apps/codeforafrica/content/pages/contact-us-join-us.md
+++ /dev/null
@@ -1,8 +0,0 @@
----
-join-us:
- title: " We are on Slack!"
- subtitle: " Join us"
- action:
- label: Join Our Slack
- href: https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform
----
diff --git a/apps/codeforafrica/content/pages/contact.md b/apps/codeforafrica/content/pages/contact.md
index 22635263e..bb7d4a0d3 100644
--- a/apps/codeforafrica/content/pages/contact.md
+++ b/apps/codeforafrica/content/pages/contact.md
@@ -60,6 +60,12 @@ contact-form:
+join-our-slack:
+ action:
+ href: https://docs.google.com/forms/d/e/1FAIpQLSdkfLU2yi2S1_7D27Z0I1TumkWy5brlam809Od9cc6CnXGA-A/viewform
+ label: Join Our Slack
+ subtitle: Join us
+ title: We are on Slack!
seo:
title: Contact Us
description: Let’s start something together!
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
index 5dc926635..dd457ff55 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
@@ -1,13 +1,10 @@
import { getCollectionBySlug } from "./utils";
function getJoinUs() {
- const { "join-us": joinUs } = getCollectionBySlug(
- "content/pages",
- "contact-us-join-us",
- ["join-us"]
- ).data;
-
- return { ...joinUs, slug: "join-our-slack" };
+ return getCollectionBySlug("content/pages", "contact", [
+ "join-our-slack",
+ "slug",
+ ]).items["join-our-slack"];
}
export default getJoinUs;
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 347590ab3..f8b203fdf 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -603,20 +603,9 @@ module.exports = {
},
],
},
- {
- ...seoFields,
- },
- ],
- },
- {
- label: "Contact Us | Join Us",
- name: "contact-us-join-us",
- file: `${APP_DIRECTORY}content/pages/contact-us-join-us.md`,
- widget: "object",
- fields: [
{
label: "Join Us",
- name: "join-us",
+ name: "join-our-slack",
widget: "object",
fields: [
{
@@ -648,6 +637,9 @@ module.exports = {
},
],
},
+ {
+ ...seoFields,
+ },
],
},
{
From 3f85399a78ef9704d308e74da18a1b579fd90ed9 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:13:20 +0300
Subject: [PATCH 26/33] Add our-work config to /projects page
---
apps/codeforafrica/content/pages/index.md | 2 +-
apps/codeforafrica/content/pages/our-work.md | 2 ++
.../codeforafrica/src/pages/api/admin/config.js | 17 +++++++++++++++--
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/apps/codeforafrica/content/pages/index.md b/apps/codeforafrica/content/pages/index.md
index e32164b03..c75137533 100644
--- a/apps/codeforafrica/content/pages/index.md
+++ b/apps/codeforafrica/content/pages/index.md
@@ -10,7 +10,7 @@ hero:
to accelerate change through data-driven initiatives.
image:
src: /images/group-4429.png
-our-projects:
+projects:
title: Projects
meet-our-team:
title: Our pan-African team is spread across the continent
diff --git a/apps/codeforafrica/content/pages/our-work.md b/apps/codeforafrica/content/pages/our-work.md
index 671475e4c..24bb5be43 100644
--- a/apps/codeforafrica/content/pages/our-work.md
+++ b/apps/codeforafrica/content/pages/our-work.md
@@ -2,6 +2,8 @@
hero:
title: Our Work
subtitle: We launch data-driven initiatives to achieve impactful results
+projects:
+ title: Projects
seo:
meta:
title: Our Work
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 7c54d03d6..52aa0e52c 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -188,8 +188,8 @@ module.exports = {
],
},
{
- label: "Our Projects",
- name: "our-projects",
+ label: "Projects",
+ name: "projects",
widget: "object",
collapsed: true,
fields: [
@@ -699,6 +699,19 @@ module.exports = {
},
],
},
+ {
+ label: "Projects",
+ name: "projects",
+ widget: "object",
+ collapsed: true,
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
From 94dd8d65a183517b9c200991c5b13beee4047ddd Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:13:41 +0300
Subject: [PATCH 27/33] Pull projects from CMS
---
.../src/lib/api.netlify-cms/getOurProjects.js | 7 ++++---
apps/codeforafrica/src/lib/index.js | 3 ++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js
index 2911aad96..ccfc31d56 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurProjects.js
@@ -1,8 +1,9 @@
import { getCollectionBySlug } from "./utils";
-const FIELD_NAME = "our-project";
-export default function geOurProjects() {
- const { slug } = getCollectionBySlug("content/pages", "index", [
+const FIELD_NAME = "projects";
+
+export default function geOurProjects(page = "index") {
+ const { slug } = getCollectionBySlug("content/pages", page, [
FIELD_NAME,
"slug",
]).items[FIELD_NAME];
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 0fb3a0cda..cbc7263f5 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -368,6 +368,7 @@ async function getProjectPageStaticProps(params) {
function getProjectsPageStaticProps() {
const seo = getSeo("our-work");
+
return {
props: {
seo,
@@ -376,7 +377,7 @@ function getProjectsPageStaticProps() {
...getHero("our-work"),
},
{
- slug: "projects",
+ ...getOurProjects("our-work"),
tags: getProjectTags(),
projects: getProjects(),
},
From 4ea5818826cbc6bbb34c7b10e32889b8b6f4c8c6 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:24:41 +0300
Subject: [PATCH 28/33] Pull stories and opportunities from CMS
---
.../content/pages/opportunities.md | 2 ++
apps/codeforafrica/content/pages/stories.md | 4 ++-
.../api.netlify-cms/getOurOpportunities.js | 12 +++++++++
.../src/lib/api.netlify-cms/getOurStories.js | 9 +++++++
.../src/lib/api.netlify-cms/index.js | 4 +++
apps/codeforafrica/src/lib/index.js | 8 +++---
.../src/pages/api/admin/config.js | 26 +++++++++++++++++++
7 files changed, 61 insertions(+), 4 deletions(-)
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getOurOpportunities.js
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getOurStories.js
diff --git a/apps/codeforafrica/content/pages/opportunities.md b/apps/codeforafrica/content/pages/opportunities.md
index f74926bc6..189461f33 100644
--- a/apps/codeforafrica/content/pages/opportunities.md
+++ b/apps/codeforafrica/content/pages/opportunities.md
@@ -2,6 +2,8 @@
hero:
title: Opportunities
subtitle: Come build digital democracies with Code for Africa
+opportunities:
+ title: Opportunities
seo:
title: Opportunities
description: Come build digital democracies with Code for Africa
diff --git a/apps/codeforafrica/content/pages/stories.md b/apps/codeforafrica/content/pages/stories.md
index 913e2e5ca..92198360a 100644
--- a/apps/codeforafrica/content/pages/stories.md
+++ b/apps/codeforafrica/content/pages/stories.md
@@ -1,4 +1,6 @@
---
+stories:
+ title: Stories
seo:
- title: "Stories"
+ title: Stories
---
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurOpportunities.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurOpportunities.js
new file mode 100644
index 000000000..756ff319d
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurOpportunities.js
@@ -0,0 +1,12 @@
+import { getCollectionBySlug } from "./utils";
+
+const FIELD_NAME = "opportunities";
+
+export default function getOurOpportunities(page = "opportunities") {
+ const { slug } = getCollectionBySlug("content/pages", page, [
+ FIELD_NAME,
+ "slug",
+ ]).items[FIELD_NAME];
+
+ return { slug };
+}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurStories.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurStories.js
new file mode 100644
index 000000000..7a14ae72f
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurStories.js
@@ -0,0 +1,9 @@
+import { getCollectionBySlug } from "./utils";
+
+const FIELD_NAME = "stories";
+
+export default function getOurStories(page = "stories") {
+ return getCollectionBySlug("content/pages", page, [FIELD_NAME, "slug"]).items[
+ FIELD_NAME
+ ];
+}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index 1992cb7a4..2a41069c4 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -7,8 +7,10 @@ import getOffices from "./getOffices";
import getOurGuidingPrinciples from "./getOurGuidingPrinciples";
import getOurImpact from "./getOurImpact";
import getOurMission from "./getOurMission";
+import getOurOpportunities from "./getOurOpportunities";
import getOurPartners from "./getOurPartners";
import getOurProjects from "./getOurProjects";
+import getOurStories from "./getOurStories";
import getOurTeam from "./getOurTeam";
import getPartners from "./getPartners";
import getCmsProjects from "./getProjects";
@@ -35,8 +37,10 @@ export {
getOurGuidingPrinciples,
getOurImpact,
getOurMission,
+ getOurOpportunities,
getOurPartners,
getOurProjects,
+ getOurStories,
getSeo,
getRelatedProjects,
getOurTeam,
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index cbc7263f5..440c58e8b 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -14,8 +14,10 @@ import {
getOurGuidingPrinciples,
getOurImpact,
getOurMission,
+ getOurOpportunities,
getOurPartners,
getOurProjects,
+ getOurStories,
getOurTeam,
getPartners,
getRelatedProjects,
@@ -249,7 +251,7 @@ async function getOpportunitiesPageStaticProps() {
...getHero("opportunities"),
},
{
- slug: "opportunities",
+ ...getOurOpportunities(),
opportunities: paginateResults(allOpportunities),
tags,
},
@@ -268,6 +270,7 @@ async function getOpportunityPageStaticProps(params) {
if (foundOpportunity) {
const { seo: pageSeo, ...opportunity } = foundOpportunity;
const seo = getSeo("opportunities-individual", pageSeo);
+
return {
props: {
seo,
@@ -399,8 +402,7 @@ async function getStoriesPageStaticProps() {
seo,
sections: [
{
- slug: "stories",
- title: "Stories",
+ ...getOurStories(),
articles: paginateResults(articles),
tags,
},
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 52aa0e52c..6495bf963 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -761,6 +761,19 @@ module.exports = {
},
],
},
+ {
+ label: "Opportunities",
+ name: "opportunities",
+ widget: "object",
+ collapsed: true,
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
@@ -781,6 +794,19 @@ module.exports = {
name: "stories",
file: `${APP_DIRECTORY}content/pages/stories.md`,
fields: [
+ {
+ label: "Stories",
+ name: "stories",
+ widget: "object",
+ collapsed: true,
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
From 318226ff00bf44db8ac9163cb56c0513caf14793 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:37:41 +0300
Subject: [PATCH 29/33] Pull related news and stories from CMS
---
.../content/pages/our-work-individual.md | 3 ++
.../content/pages/stories-individual.md | 3 ++
apps/codeforafrica/src/lib/index.js | 21 ++++++----
.../src/pages/api/admin/config.js | 42 +++++++++++++++++++
.../src/pages/projects/[slug]/index.page.js | 2 +-
.../src/pages/stories/[slug].page.js | 2 +-
6 files changed, 63 insertions(+), 10 deletions(-)
diff --git a/apps/codeforafrica/content/pages/our-work-individual.md b/apps/codeforafrica/content/pages/our-work-individual.md
index 850c8658c..9124932ea 100644
--- a/apps/codeforafrica/content/pages/our-work-individual.md
+++ b/apps/codeforafrica/content/pages/our-work-individual.md
@@ -1,4 +1,7 @@
---
+news-stories:
+ title: Related stories
+ articles-count: 3
related-projects:
title: Explore other projects
seo:
diff --git a/apps/codeforafrica/content/pages/stories-individual.md b/apps/codeforafrica/content/pages/stories-individual.md
index 8e8932b4f..6e9fe4d1c 100644
--- a/apps/codeforafrica/content/pages/stories-individual.md
+++ b/apps/codeforafrica/content/pages/stories-individual.md
@@ -1,4 +1,7 @@
---
+news-stories:
+ title: Recent stories
+ articles-count: 3
seo:
title-template: "%s | Stories | Code for Africa"
---
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 440c58e8b..e1534c761 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -328,6 +328,7 @@ async function getProjectPageStaticProps(params) {
);
if (project) {
+ const { title, count = 3, slug } = getNewsAndStories("our-work-individual");
const relatedStories = await getRelatedStoriesByTags([project.name]);
const relatedProjects = getRelatedProjects("our-work-individual");
const seo = getSeo("our-work-individual", {
@@ -349,9 +350,9 @@ async function getProjectPageStaticProps(params) {
team: project?.team?.list,
},
{
- slug: "related-stories",
- title: "Related stories",
- articles: relatedStories.slice(0, 3),
+ slug,
+ title,
+ articles: relatedStories.slice(0, count),
},
{
...relatedProjects,
@@ -415,24 +416,28 @@ async function getStoriesPageStaticProps() {
}
async function getStoryPageStaticProps(slug) {
- // TODO: is this the best way to get the article slug?
const actualSlug = slug.slug.split("/")[2];
const story = await getStory(actualSlug);
const relatedArticles = await getRelatedStoriesByTags(story.tags, story);
- // check for empty obj
if (story) {
+ const {
+ title,
+ count = 3,
+ slug: articlesSlug,
+ } = getNewsAndStories("stories-individual");
const { seo: pageSeo, ...article } = story;
const seo = getSeo("stories-individual", pageSeo);
+
return {
props: {
seo,
article,
sections: [
{
- slug: "related-stories",
- title: "News and Stories",
- articles: relatedArticles?.slice(0, 3) ?? null,
+ slug: articlesSlug,
+ title,
+ articles: relatedArticles?.slice(0, count) ?? null,
},
],
footer,
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 6495bf963..978588056 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -722,6 +722,27 @@ module.exports = {
name: "our-work-individual",
file: `${APP_DIRECTORY}content/pages/our-work-individual.md`,
fields: [
+ {
+ label: "Related Stories",
+ name: "news-stories",
+ widget: "object",
+ collapsed: true,
+ summary: "{{fields.title}}",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ {
+ label: "Number of stories",
+ name: "articles-count",
+ widget: "number",
+ value_type: "int",
+ min: 3,
+ },
+ ],
+ },
{
label: "Related Projects",
name: "related-projects",
@@ -817,6 +838,27 @@ module.exports = {
name: "stories-individual",
file: `${APP_DIRECTORY}content/pages/stories-individual.md`,
fields: [
+ {
+ label: "Related Stories",
+ name: "news-stories",
+ widget: "object",
+ collapsed: true,
+ summary: "{{fields.title}}",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ {
+ label: "Number of stories",
+ name: "articles-count",
+ widget: "number",
+ value_type: "int",
+ min: 3,
+ },
+ ],
+ },
{
...seoFields,
},
diff --git a/apps/codeforafrica/src/pages/projects/[slug]/index.page.js b/apps/codeforafrica/src/pages/projects/[slug]/index.page.js
index 9ec56095a..f08654352 100644
--- a/apps/codeforafrica/src/pages/projects/[slug]/index.page.js
+++ b/apps/codeforafrica/src/pages/projects/[slug]/index.page.js
@@ -54,7 +54,7 @@ function Index({ project, sections, ...props }) {
/>
);
- case "related-stories":
+ case "news-stories":
return (
: null}
{sections?.map((section) => {
switch (section.slug) {
- case "related-stories":
+ case "news-stories":
return (
Date: Fri, 9 Sep 2022 12:46:35 +0300
Subject: [PATCH 30/33] Pull team content from CMS
---
.../content/pages/our-work-individual.md | 2 ++
.../src/lib/api.netlify-cms/getProjectTeam.js | 9 +++++++++
apps/codeforafrica/src/lib/api.netlify-cms/index.js | 2 ++
apps/codeforafrica/src/lib/index.js | 6 +++---
apps/codeforafrica/src/pages/api/admin/config.js | 12 ++++++++++++
5 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getProjectTeam.js
diff --git a/apps/codeforafrica/content/pages/our-work-individual.md b/apps/codeforafrica/content/pages/our-work-individual.md
index 9124932ea..1ae2678ee 100644
--- a/apps/codeforafrica/content/pages/our-work-individual.md
+++ b/apps/codeforafrica/content/pages/our-work-individual.md
@@ -1,4 +1,6 @@
---
+team:
+ title: Team
news-stories:
title: Related stories
articles-count: 3
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getProjectTeam.js b/apps/codeforafrica/src/lib/api.netlify-cms/getProjectTeam.js
new file mode 100644
index 000000000..7aba99fef
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getProjectTeam.js
@@ -0,0 +1,9 @@
+import { getCollectionBySlug } from "./utils";
+
+const FIELD_NAME = "team";
+
+export default function getProjectTeam(page = "our-work-individual") {
+ return getCollectionBySlug("content/pages", page, [FIELD_NAME, "slug"]).items[
+ FIELD_NAME
+ ];
+}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index 2a41069c4..03f78ca13 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -14,6 +14,7 @@ import getOurStories from "./getOurStories";
import getOurTeam from "./getOurTeam";
import getPartners from "./getPartners";
import getCmsProjects from "./getProjects";
+import getProjectTeam from "./getProjectTeam";
import getRelatedProjects from "./getRelatedProjects";
import getTeam from "./getTeam";
import getFooter from "./sections/getFooter";
@@ -45,5 +46,6 @@ export {
getRelatedProjects,
getOurTeam,
getPartners,
+ getProjectTeam,
getTeam,
};
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index e1534c761..e626cd676 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -20,6 +20,7 @@ import {
getOurStories,
getOurTeam,
getPartners,
+ getProjectTeam,
getRelatedProjects,
getTeam,
getSeo,
@@ -345,9 +346,8 @@ async function getProjectPageStaticProps(params) {
project,
sections: [
{
- slug: "team",
- title: "Team",
- team: project?.team?.list,
+ ...getProjectTeam(),
+ team: project?.team?.list || null,
},
{
slug,
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index 978588056..6c21772cf 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -722,6 +722,18 @@ module.exports = {
name: "our-work-individual",
file: `${APP_DIRECTORY}content/pages/our-work-individual.md`,
fields: [
+ {
+ label: "Team",
+ name: "team",
+ widget: "object",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
label: "Related Stories",
name: "news-stories",
From f877a1bb662419651eb60c79ecdff444464eb8d0 Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 12:58:28 +0300
Subject: [PATCH 31/33] Pull contact form from CMS
---
.../src/lib/api.netlify-cms/getContactForm.js | 16 +++++++++-------
apps/codeforafrica/src/lib/index.js | 1 -
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js b/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
index 717771a22..f30853e50 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getContactForm.js
@@ -1,13 +1,15 @@
import { getCollectionBySlug } from "./utils";
+const FIELD_NAME = "contact-form";
+
function getContactForm() {
- const { "contact-form": contactForm } = getCollectionBySlug(
- "content/pages",
- "contact",
- ["contact-form"]
- ).items;
- const { "embed-code": embedCode } = contactForm || {};
- return { embedCode };
+ const contactForm = getCollectionBySlug("content/pages", "contact", [
+ FIELD_NAME,
+ "slug",
+ ]).items[FIELD_NAME];
+ const { "embed-code": embedCode, slug } = contactForm || {};
+
+ return { embedCode, slug };
}
export default getContactForm;
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index e626cd676..4ef02fd36 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -685,7 +685,6 @@ function getContactPageStaticProps() {
},
{
...getContactForm(),
- slug: "contact-form",
},
{
...getJoinUs(),
From 0098e5daf9b8e84f2c63ebf7677b81aa4cefb86d Mon Sep 17 00:00:00 2001
From: _ Kilemensi
Date: Fri, 9 Sep 2022 13:04:43 +0300
Subject: [PATCH 32/33] Pull our offices from CMS
---
apps/codeforafrica/content/pages/contact.md | 2 ++
.../src/lib/api.netlify-cms/getOurOffices.js | 9 +++++++++
.../codeforafrica/src/lib/api.netlify-cms/index.js | 2 ++
apps/codeforafrica/src/lib/index.js | 4 ++--
apps/codeforafrica/src/pages/api/admin/config.js | 14 +++++++++++++-
apps/codeforafrica/src/pages/contact/index.page.js | 2 +-
6 files changed, 29 insertions(+), 4 deletions(-)
create mode 100644 apps/codeforafrica/src/lib/api.netlify-cms/getOurOffices.js
diff --git a/apps/codeforafrica/content/pages/contact.md b/apps/codeforafrica/content/pages/contact.md
index bb7d4a0d3..6d3c42886 100644
--- a/apps/codeforafrica/content/pages/contact.md
+++ b/apps/codeforafrica/content/pages/contact.md
@@ -66,6 +66,8 @@ join-our-slack:
label: Join Our Slack
subtitle: Join us
title: We are on Slack!
+our-offices:
+ title: Our Offices
seo:
title: Contact Us
description: Let’s start something together!
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurOffices.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurOffices.js
new file mode 100644
index 000000000..e9572e71c
--- /dev/null
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurOffices.js
@@ -0,0 +1,9 @@
+import { getCollectionBySlug } from "./utils";
+
+const FIELD_NAME = "our-offices";
+
+export default function getOurOffices(page = "contact") {
+ return getCollectionBySlug("content/pages", page, [FIELD_NAME, "slug"]).items[
+ FIELD_NAME
+ ];
+}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/index.js b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
index 03f78ca13..40a521cc0 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/index.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/index.js
@@ -7,6 +7,7 @@ import getOffices from "./getOffices";
import getOurGuidingPrinciples from "./getOurGuidingPrinciples";
import getOurImpact from "./getOurImpact";
import getOurMission from "./getOurMission";
+import getOurOffices from "./getOurOffices";
import getOurOpportunities from "./getOurOpportunities";
import getOurPartners from "./getOurPartners";
import getOurProjects from "./getOurProjects";
@@ -38,6 +39,7 @@ export {
getOurGuidingPrinciples,
getOurImpact,
getOurMission,
+ getOurOffices,
getOurOpportunities,
getOurPartners,
getOurProjects,
diff --git a/apps/codeforafrica/src/lib/index.js b/apps/codeforafrica/src/lib/index.js
index 4ef02fd36..c44377f1c 100644
--- a/apps/codeforafrica/src/lib/index.js
+++ b/apps/codeforafrica/src/lib/index.js
@@ -14,6 +14,7 @@ import {
getOurGuidingPrinciples,
getOurImpact,
getOurMission,
+ getOurOffices,
getOurOpportunities,
getOurPartners,
getOurProjects,
@@ -690,8 +691,7 @@ function getContactPageStaticProps() {
...getJoinUs(),
},
{
- slug: "office-addresses",
- title: "Our Offices",
+ ...getOurOffices(),
addresses: getOffices(),
map: {
apiKey: process.env.GOOGLE_MAPS_API_KEY ?? null,
diff --git a/apps/codeforafrica/src/pages/api/admin/config.js b/apps/codeforafrica/src/pages/api/admin/config.js
index d8b31a27e..c6bcbd32e 100644
--- a/apps/codeforafrica/src/pages/api/admin/config.js
+++ b/apps/codeforafrica/src/pages/api/admin/config.js
@@ -631,7 +631,7 @@ module.exports = {
],
},
{
- label: "Join Us",
+ label: "Join our Slack",
name: "join-our-slack",
widget: "object",
fields: [
@@ -664,6 +664,18 @@ module.exports = {
},
],
},
+ {
+ label: "Our offices",
+ name: "our-offices",
+ widget: "object",
+ fields: [
+ {
+ label: "Title",
+ name: "title",
+ widget: "string",
+ },
+ ],
+ },
{
...seoFields,
},
diff --git a/apps/codeforafrica/src/pages/contact/index.page.js b/apps/codeforafrica/src/pages/contact/index.page.js
index a78a5741f..59e262683 100644
--- a/apps/codeforafrica/src/pages/contact/index.page.js
+++ b/apps/codeforafrica/src/pages/contact/index.page.js
@@ -32,7 +32,7 @@ function ContactPage({ sections, ...props }) {
/>
);
}
- case "office-addresses": {
+ case "our-offices": {
return (
Date: Fri, 9 Sep 2022 16:54:09 +0300
Subject: [PATCH 33/33] Refractore some hard coded content
---
.../src/lib/api.netlify-cms/getGetInTouch.js | 6 ++++--
apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js | 8 ++++----
.../src/lib/api.netlify-cms/getOurGuidingPrinciples.js | 7 +++++--
.../codeforafrica/src/lib/api.netlify-cms/getOurImpact.js | 3 ++-
.../src/lib/api.netlify-cms/getOurMission.js | 3 ++-
.../src/lib/api.netlify-cms/getOurPartners.js | 3 ++-
.../src/lib/api.netlify-cms/sections/getHero.js | 3 ++-
7 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js b/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
index 44fd9e6cb..c9fb5a508 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getGetInTouch.js
@@ -1,6 +1,8 @@
import { getCollectionBySlug } from "./utils";
+const FIELD_NAME = "get-in-touch";
+
export default function getGetInTouch() {
- return getCollectionBySlug("content/pages", "about", ["get-in-touch", "slug"])
- .items["get-in-touch"];
+ return getCollectionBySlug("content/pages", "about", [FIELD_NAME, "slug"])
+ .items[FIELD_NAME];
}
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
index dd457ff55..fcd77e8a1 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getJoinUs.js
@@ -1,10 +1,10 @@
import { getCollectionBySlug } from "./utils";
+const FIELD_NAME = "join-our-slack";
+
function getJoinUs() {
- return getCollectionBySlug("content/pages", "contact", [
- "join-our-slack",
- "slug",
- ]).items["join-our-slack"];
+ return getCollectionBySlug("content/pages", "contact", [FIELD_NAME, "slug"])
+ .items[FIELD_NAME];
}
export default getJoinUs;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
index 91edd9280..c5c6ad594 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurGuidingPrinciples.js
@@ -5,13 +5,16 @@ import { getCollectionBySlug } from "./utils";
const pagesDir = join(process.cwd(), "content/pages");
+const FIELD_NAME = "guiding-principles";
+
function getOurGuidingPrinciples() {
const {
title,
"guiding-principle-list": principleIds,
slug,
- } = getCollectionBySlug(pagesDir, "about", ["guiding-principles", "slug"])
- .items["guiding-principles"];
+ } = getCollectionBySlug(pagesDir, "about", [FIELD_NAME, "slug"]).items[
+ FIELD_NAME
+ ];
const allPrinciples = getGuidingPrinciples([
"id",
"title",
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
index 5fc9e49dd..ca7c8aca4 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurImpact.js
@@ -4,6 +4,7 @@ import getImpactList from "./getImpactList";
import { getCollectionBySlug } from "./utils";
const pageDir = join(process.cwd(), "content/pages");
+const FIELD_NAME = "our-impact";
export default function geOurImpact(page = "index") {
const {
@@ -13,7 +14,7 @@ export default function geOurImpact(page = "index") {
title = null,
slug = null,
},
- } = getCollectionBySlug(pageDir, page, ["our-impact", "slug"]).items;
+ } = getCollectionBySlug(pageDir, page, [FIELD_NAME, "slug"]).items;
const impact = getImpactList();
// Need to maintain order of how impact were selected in ourImpact
const list = impactIds?.map((id) => impact.find((i) => i.id === id)) ?? null;
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
index 81196da3e..626fd601e 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurMission.js
@@ -5,10 +5,11 @@ import { marked } from "marked";
import { getCollectionBySlug } from "./utils";
const pagesDir = join(process.cwd(), "content/pages");
+const FIELD_NAME = "our-mission";
export default function getOurMission() {
const { "our-mission": ourMission } = getCollectionBySlug(pagesDir, "about", [
- "our-mission",
+ FIELD_NAME,
"slug",
]).items;
ourMission.description = marked(ourMission.description);
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js b/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js
index a74b8fbf5..2a4b2f367 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/getOurPartners.js
@@ -6,6 +6,7 @@ import getPartners from "./getPartners";
import { getCollectionBySlug } from "./utils";
const pageDir = join(process.cwd(), "content/pages");
+const FIELD_NAME = "our-partners";
export default function geOurPartners(page = "index") {
const {
@@ -15,7 +16,7 @@ export default function geOurPartners(page = "index") {
"partners-list": partnersIds,
action = null,
},
- } = getCollectionBySlug(pageDir, page, ["our-partners", "slug"]).items;
+ } = getCollectionBySlug(pageDir, page, [FIELD_NAME, "slug"]).items;
const title = marked.parseInline(originalTitle);
const allPartners = getPartners([
"id",
diff --git a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
index f38a4212c..69ceedb89 100644
--- a/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
+++ b/apps/codeforafrica/src/lib/api.netlify-cms/sections/getHero.js
@@ -5,8 +5,9 @@ import { marked } from "marked";
import { getCollectionBySlug } from "../utils";
const indexPageDir = join(process.cwd(), "content/pages");
+const FIELD_NAME = "hero";
-export default function getHero(page, fields = ["hero", "slug"]) {
+export default function getHero(page, fields = [FIELD_NAME, "slug"]) {
const { hero } = getCollectionBySlug(indexPageDir, page, fields).items;
hero.title = marked.parseInline(hero.title);