Skip to content

Commit

Permalink
Use rest of queries
Browse files Browse the repository at this point in the history
  • Loading branch information
kelvinkipruto committed Sep 25, 2023
1 parent d6ed390 commit 6d27479
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apps/codeforafrica/src/lib/data/blockify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ const propsifyBlockBySlug = {
stories,
};

async function blockify(blocks, api) {
async function blockify(blocks, api, context) {
const promises = blocks?.map(async (block) => {
const slug = block.blockType;
const propsifyBlock = propsifyBlockBySlug[slug];

if (propsifyBlock) {
return propsifyBlock(block, api);
return propsifyBlock(block, api, context);
}
return {
...block,
Expand Down
4 changes: 3 additions & 1 deletion apps/codeforafrica/src/lib/data/blockify/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
formatStory,
} from "@/codeforafrica/lib/data/utils/stories";

async function stories(block, api) {
async function stories(block, api, context) {
const { query } = context;
const { featured, title, labels } = block;
const featuredStory = featured && (formatStory(featured) || null);
const featuredStorySlug = featuredStory
Expand All @@ -18,6 +19,7 @@ async function stories(block, api) {
},
},
}),
...query,
};

const {
Expand Down
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export async function getPageProps(api, context) {
if (params?.slugs?.length > 2) {
page = await pagify(page, api, context);
}
const blocks = await blockify(page?.blocks, api);
const blocks = await blockify(page?.blocks, api, context);
const settings = await api.findGlobal("settings");
const navbar = getNavBar(settings);
const footer = getFooter(settings);
Expand Down

0 comments on commit 6d27479

Please sign in to comment.