diff --git a/apps/codeforafrica/src/lib/data/common/index.js b/apps/codeforafrica/src/lib/data/common/index.js index 2a6129449..57046732a 100644 --- a/apps/codeforafrica/src/lib/data/common/index.js +++ b/apps/codeforafrica/src/lib/data/common/index.js @@ -44,14 +44,62 @@ function getPageSlug({ params }) { return params?.slugs?.[pageSlugIndex] || "index"; } -function getDefaultErrorPageProps() { +function getDefaultErrorPageProps(statusCode = 404) { + if (statusCode === 500) { + return { + title: "Server Error. ", + subtitle: [ + { + children: [ + { + text: "Don't worry!, you can head back to our ", + children: null, + }, + { + type: "link", + newTab: false, + url: "/", + children: [ + { + text: "homepage", + children: null, + }, + ], + href: "/", + }, + { + text: "check out our most recent ", + children: null, + }, + { + type: "link", + newTab: false, + url: "/projects", + children: [ + { + text: "projects", + children: null, + }, + ], + href: "/projects", + }, + { + text: ", or read below some of the contents produced by our amazing team while the technical team is working on fixing the issue.", + children: null, + }, + ], + }, + ], + }; + } + return { - title: "Page not found. ", + title: "Whoops! This page got lost in conversation! ", subtitle: [ { children: [ { - text: "Visit our ", + text: "Don't worry!, you can head back to our ", children: null, }, { @@ -66,6 +114,26 @@ function getDefaultErrorPageProps() { ], href: "/", }, + { + text: "check out our most recent ", + children: null, + }, + { + type: "link", + newTab: false, + url: "/projects", + children: [ + { + text: "projects", + children: null, + }, + ], + href: "/projects", + }, + { + text: ", or read below some of the contents produced by our amazing team.", + children: null, + }, ], }, ], @@ -77,7 +145,10 @@ export async function getPageProps(api, context) { const { docs: [page], } = await api.findPage(slug); - if (!page && (slug === "404" || slug === "500")) { + if (!page) { + if (slug === "500") { + return getDefaultErrorPageProps(500); + } return getDefaultErrorPageProps(); } if (!page) {