Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ft/codeforafrica join our slack #588

Merged
merged 8 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import hero from "./hero";
import joinOurSlack from "./joinOurSlack";

const propsifyBlockBySlug = {
hero,
"join-our-slack": joinOurSlack,
};

async function blockify(blocks) {
Expand Down
14 changes: 14 additions & 0 deletions apps/codeforafrica/src/lib/data/blockify/joinOurSlack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { actionFromActionButton } from "@/codeforafrica/lib/data/utils";

function joinOurSlack(block) {
const { actionButton, ...other } = block;
const action = actionFromActionButton({ ...actionButton });

return {
...other,
action,
slug: "join-our-slack",
};
}

export default joinOurSlack;
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/rest/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export const api = {
export async function getPageStaticProps(context) {
const props = await getPageProps(api, context);
return {
props,
props: props || {},
};
}
4 changes: 4 additions & 0 deletions apps/codeforafrica/src/lib/data/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ export function imageFromMedia({ alt = null, url = null }) {
return { alt, src: url };
}

export function actionFromActionButton({ href, label, newTab = false }) {
return { href, label, newTab };
}

export default undefined;
2 changes: 2 additions & 0 deletions apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import CustomPageHeader from "@/codeforafrica/components/CustomPageHeader";
import FeaturedProjects from "@/codeforafrica/components/FeaturedProjects";
import GetInvolved from "@/codeforafrica/components/GetInvolved";
import Hero from "@/codeforafrica/components/Hero";
import JoinOurSlack from "@/codeforafrica/components/JoinOurSlack";
import MeetOurTeam from "@/codeforafrica/components/MeetOurTeam";
import NewsAndStories from "@/codeforafrica/components/NewsAndStories";
import OurPartners from "@/codeforafrica/components/OurPartners";
Expand All @@ -13,6 +14,7 @@ import { getPageServerSideProps } from "@/codeforafrica/lib/data";

const componentsBySlugs = {
hero: Hero,
"join-our-slack": JoinOurSlack,
"page-header": PageHeader,
"custom-page-header": CustomPageHeader,
"meet-our-team": MeetOurTeam,
Expand Down
37 changes: 37 additions & 0 deletions apps/codeforafrica/src/payload/blocks/JoinOurSlack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import link from "../fields/links/link";

const JoinOurSlack = {
slug: "join-our-slack",
imageURL: "/images/cms/blocks/join_our_slack.jpg",
imageAltText: "Display link to join our Slack community",
fields: [
{
name: "title",
label: "Title",
required: true,
type: "text",
},
{
name: "subtitle",
label: "Sub Title",
required: true,
type: "text",
},
{
name: "actionButton",
label: "Action Button",
type: "group",
fields: [
{
name: "label",
label: "Label",
type: "text",
required: true,
},
link({}),
],
},
],
};

export default JoinOurSlack;
10 changes: 9 additions & 1 deletion apps/codeforafrica/src/payload/collections/Pages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CustomPageHeader from "../blocks/CustomPageHeader";
import Error from "../blocks/Error";
import Hero from "../blocks/Hero";
import JoinOurSlack from "../blocks/JoinOurSlack";
import OurPartners from "../blocks/OurPartners";
import PageHeader from "../blocks/PageHeader";
import fullTitle from "../fields/fullTitle";
Expand Down Expand Up @@ -37,7 +38,14 @@ const Pages = {
// each other e.g. while alphabecially CustomPageHeader should be with C,
// it's functiaonally equivalent with PageHeader so we keep it next to
// PageHeader
blocks: [Error, Hero, PageHeader, CustomPageHeader, OurPartners],
blocks: [
Error,
Hero,
JoinOurSlack,
PageHeader,
CustomPageHeader,
OurPartners,
],
admin: {
initCollapsed: true,
},
Expand Down