Skip to content

Commit

Permalink
Pagify
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Sep 18, 2023
1 parent 6d8a4e1 commit 0655057
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/blockify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const propsifyBlockBySlug = {

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

if (propsifyBlock) {
Expand Down
13 changes: 4 additions & 9 deletions apps/codeforafrica/src/lib/data/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,22 @@ function getPageSlug({ params }) {
export async function getPageProps(api, context) {
const { params } = context;
const slug = getPageSlug(context);
const {
let {
docs: [page],
} = await api.findPage(slug);
if (!page) {
return null;
}
let props;
if (params?.slugs?.length > 2) {
props = await pagify(page, api, context);
} else {
const blocks = await blockify(page.blocks);
props = {
blocks,
};
page = await pagify(page, api, context);
}
const blocks = await blockify(page.blocks);
const settings = await api.findGlobal("settings");
const navbar = getNavBar(settings);
const footer = getFooter(settings);

return {
...props,
blocks,
footer,
navbar,
};
Expand Down

0 comments on commit 0655057

Please sign in to comment.