From 13398a2f2575ac6d34b2eb5017a1fd95f9f8d30e Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:31:26 +0300 Subject: [PATCH] Stories block --- .../src/lib/data/blockify/index.js | 2 ++ .../src/lib/data/blockify/stories.js | 32 +++++++++++++++++++ .../src/lib/data/longform/index.js | 0 3 files changed, 34 insertions(+) create mode 100644 apps/codeforafrica/src/lib/data/blockify/stories.js create mode 100644 apps/codeforafrica/src/lib/data/longform/index.js diff --git a/apps/codeforafrica/src/lib/data/blockify/index.js b/apps/codeforafrica/src/lib/data/blockify/index.js index 696f0540e..6a87db0fa 100644 --- a/apps/codeforafrica/src/lib/data/blockify/index.js +++ b/apps/codeforafrica/src/lib/data/blockify/index.js @@ -2,12 +2,14 @@ import getInvolved from "./get-involved"; import hero from "./hero"; import meetOurTeam from "./meetOurTeam"; import ourImpact from "./our-impact"; +import stories from "./stories"; const propsifyBlockBySlug = { hero, "meet-our-team": meetOurTeam, "our-impact": ourImpact, "get-involved": getInvolved, + "stories-list": stories, }; async function blockify(blocks) { diff --git a/apps/codeforafrica/src/lib/data/blockify/stories.js b/apps/codeforafrica/src/lib/data/blockify/stories.js new file mode 100644 index 000000000..98d2eb869 --- /dev/null +++ b/apps/codeforafrica/src/lib/data/blockify/stories.js @@ -0,0 +1,32 @@ +import { imageFromMedia } from "@/codeforafrica/lib/data/utils"; + +function stories(block) { + const { featured = {}, title, search, excerpt, ...other } = block; + const { + title: featuredStoryTitle, + coverImage: featuredStoryCoverImage, + excerpt: featuredStoryExcerpt, + } = featured; + + const featuredStory = { + title: featuredStoryTitle, + image: imageFromMedia({ + alt: featuredStoryTitle, + ...featuredStoryCoverImage, + }), + excerpt: featuredStoryExcerpt, + slug: "featured-story", + }; + + const storiesList = { + ...other, + slug: "stories-list", + }; + + return { + ...featuredStory, + storiesList, + }; +} + +export default stories; diff --git a/apps/codeforafrica/src/lib/data/longform/index.js b/apps/codeforafrica/src/lib/data/longform/index.js new file mode 100644 index 000000000..e69de29bb