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(