diff --git a/examples/magento-graphcms/pages/blog/[...url].tsx b/examples/magento-graphcms/pages/blog/[...url].tsx index 48d7f8f603..0f666a45a9 100644 --- a/examples/magento-graphcms/pages/blog/[...url].tsx +++ b/examples/magento-graphcms/pages/blog/[...url].tsx @@ -1,6 +1,6 @@ import { PageOptions } from '@graphcommerce/framer-next-pages' import { hygraphPageContent, HygraphPagesQuery } from '@graphcommerce/graphcms-ui' -import { StoreConfigDocument } from '@graphcommerce/magento-store' +import { redirectOrNotFound, StoreConfigDocument } from '@graphcommerce/magento-store' import { PageMeta, BlogTitle, @@ -93,7 +93,9 @@ export const getStaticProps: GetPageStaticProps = async ({ locale, params }) => query: BlogListDocument, variables: { currentUrl: [`blog/${urlKey}`], first: limit }, }) - if (!(await page).data.pages?.[0]) return { notFound: true } + + if (!(await page).data.pages?.[0]) + return redirectOrNotFound(staticClient, conf, { url: `blog/${urlKey}` }, locale) return { props: { diff --git a/examples/magento-graphcms/pages/blog/tagged/[url].tsx b/examples/magento-graphcms/pages/blog/tagged/[url].tsx index ea67f06753..a588604ea8 100644 --- a/examples/magento-graphcms/pages/blog/tagged/[url].tsx +++ b/examples/magento-graphcms/pages/blog/tagged/[url].tsx @@ -1,6 +1,6 @@ import { PageOptions } from '@graphcommerce/framer-next-pages' import { hygraphPageContent, HygraphPagesQuery } from '@graphcommerce/graphcms-ui' -import { StoreConfigDocument } from '@graphcommerce/magento-store' +import { redirectOrNotFound, StoreConfigDocument } from '@graphcommerce/magento-store' import { PageMeta, GetStaticProps, Row, LayoutTitle, LayoutHeader } from '@graphcommerce/next-ui' import { i18n } from '@lingui/core' import { Trans } from '@lingui/react' @@ -90,7 +90,9 @@ export const getStaticProps: GetPageStaticProps = async ({ locale, params }) => query: BlogListTaggedDocument, variables: { currentUrl: [`blog/tagged/${urlKey}`], first: limit, tagged: params?.url }, }) - if (!(await page).data.pages?.[0]) return { notFound: true } + + if (!(await page).data.pages?.[0]) + return redirectOrNotFound(staticClient, conf, { url: `blog/${urlKey}` }, locale) return { props: { diff --git a/examples/magento-graphcms/pages/service/[[...url]].tsx b/examples/magento-graphcms/pages/service/[[...url]].tsx index 725cc4fbb0..f94bd6def7 100644 --- a/examples/magento-graphcms/pages/service/[[...url]].tsx +++ b/examples/magento-graphcms/pages/service/[[...url]].tsx @@ -4,7 +4,7 @@ import { hygraphPageContent, HygraphPagesQuery, } from '@graphcommerce/graphcms-ui' -import { StoreConfigDocument } from '@graphcommerce/magento-store' +import { StoreConfigDocument, redirectOrNotFound } from '@graphcommerce/magento-store' import { PageMeta, GetStaticProps, LayoutOverlayHeader, LayoutTitle } from '@graphcommerce/next-ui' import { i18n } from '@lingui/core' import { Container } from '@mui/material' @@ -84,7 +84,7 @@ export const getStaticProps: GetPageStaticProps = async ({ locale, params }) => const page = hygraphPageContent(staticClient, url) const layout = staticClient.query({ query: LayoutDocument, fetchPolicy: 'cache-first' }) - if (!(await page).data.pages?.[0]) return { notFound: true } + if (!(await page).data.pages?.[0]) return redirectOrNotFound(staticClient, conf, { url }, locale) const isRoot = url === 'service'