diff --git a/api/ssr.mjs b/api/ssr.mjs index b2e8e468..81b1b5e8 100644 --- a/api/ssr.mjs +++ b/api/ssr.mjs @@ -7,7 +7,8 @@ export default async function handler(req, res) { const { httpResponse, errorWhileRendering } = pageContext - console.error(errorWhileRendering) + console.error('pageContext', pageContext) + console.error('errorWhileRendering', errorWhileRendering) // if (errorWhileRendering) { // console.error(errorWhileRendering) diff --git a/src/pages/article.page.tsx b/src/pages/article.page.tsx index 27164df8..f96cc748 100644 --- a/src/pages/article.page.tsx +++ b/src/pages/article.page.tsx @@ -3,11 +3,12 @@ import type { Shout } from '../graphql/types.gen' import { PageLayout } from '../components/_shared/PageLayout' import type { PageProps } from './types' import { loadShout, useArticlesStore } from '../stores/zine/articles' -import { useRouter } from '../stores/router' +import { router, useRouter } from '../stores/router' import { Loading } from '../components/_shared/Loading' import { ReactionsProvider } from '../context/reactions' import { FullArticle } from '../components/Article/FullArticle' import { setPageLoadManagerPromise } from '../utils/pageLoadManager' +import { redirectPage } from '@nanostores/router' export const ArticlePage = (props: PageProps) => { const shouts = props.article ? [props.article] : [] @@ -28,7 +29,10 @@ export const ArticlePage = (props: PageProps) => { const loadShoutPromise = loadShout(slug()) setPageLoadManagerPromise(loadShoutPromise) await loadShoutPromise - // тут видимо тоже что-то нужно написать + + if (!article()) { + redirectPage(router, 'fourOuFour') + } } }) diff --git a/src/stores/zine/articles.ts b/src/stores/zine/articles.ts index a993aef6..3630550e 100644 --- a/src/stores/zine/articles.ts +++ b/src/stores/zine/articles.ts @@ -119,6 +119,9 @@ const addSortedArticles = (articles: Shout[]) => { export const loadShout = async (slug: string): Promise => { const newArticle = await apiClient.getShoutBySlug(slug) + if (!newArticle) { + return + } addArticles([newArticle]) const newArticleIndex = sortedArticles().findIndex((s) => s.id === newArticle.id) if (newArticleIndex >= 0) {