From 66db738ba5e42eb14d8518b273ca8d8196a17e59 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Tue, 5 Nov 2024 13:35:08 +0300 Subject: [PATCH] Fixed disabled hurumap --- .../src/lib/data/blockify/hero.js | 5 ++--- .../src/lib/data/common/index.js | 13 +++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/apps/climatemappedafrica/src/lib/data/blockify/hero.js b/apps/climatemappedafrica/src/lib/data/blockify/hero.js index 66b91a3e0..14909bac4 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/hero.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/hero.js @@ -6,10 +6,9 @@ import { export default async function hero({ block, hurumap }) { const { rootGeography: { center, code, rootGeographyHasData: pinRootGeography }, - page: { - value: { slug: explorePageSlug }, - }, + page, } = hurumap; + const explorePageSlug = page?.value?.slug ?? null; const { geometries } = await fetchProfileGeography(code.toLowerCase()); const { level } = geometries.boundary?.properties ?? {}; const childLevelMaps = { diff --git a/apps/climatemappedafrica/src/lib/data/common/index.js b/apps/climatemappedafrica/src/lib/data/common/index.js index 939d7a362..cf3c2e0e1 100644 --- a/apps/climatemappedafrica/src/lib/data/common/index.js +++ b/apps/climatemappedafrica/src/lib/data/common/index.js @@ -65,12 +65,7 @@ async function getNavBar(siteSettings, variant, { slug }, hurumapProfile) { export async function getPagePaths(api) { const hurumapSettings = await api.findGlobal("settings-hurumap"); const { docs: pages } = await api.getCollection("pages"); - let explorePage; - if (hurumapSettings.page) { - explorePage = hurumapSettings.page.value; - } else { - explorePage = null; - } + const explorePage = hurumapSettings.page?.value || { slug: null }; const paths = pages.flatMap(({ slug }) => { // TODO(kilemensi): Handle parent > child page relation e.g. /insights/news if (slug !== explorePage?.slug) { @@ -112,9 +107,7 @@ export async function getPageProps(api, context) { } const hurumap = await api.findGlobal("settings-hurumap"); - const { - page: { value: explorePage }, - } = hurumap; + const explorePage = hurumap.page?.value || { slug: null }; const siteSettings = await api.findGlobal("settings-site"); const settings = { @@ -124,7 +117,7 @@ export async function getPageProps(api, context) { }; let blocks = await blockify(page.blocks, api, context, settings); - const variant = page.slug === explorePage.slug ? "explore" : "default"; + const variant = page.slug === explorePage?.slug ? "explore" : "default"; const footer = getFooter(siteSettings, variant); const menus = await getNavBar(