This commit is contained in:
Igor Lobanov 2023-11-04 14:40:55 +01:00
parent d20e546d69
commit 9e46f7d4fb
3 changed files with 11 additions and 3 deletions

View File

@ -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)

View File

@ -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')
}
}
})

View File

@ -119,6 +119,9 @@ const addSortedArticles = (articles: Shout[]) => {
export const loadShout = async (slug: string): Promise<void> => {
const newArticle = await apiClient.getShoutBySlug(slug)
if (!newArticle) {
return
}
addArticles([newArticle])
const newArticleIndex = sortedArticles().findIndex((s) => s.id === newArticle.id)
if (newArticleIndex >= 0) {