debug: add logs in dev variant of slug/tab
This commit is contained in:
parent
db8b53f9bd
commit
91d8fdf746
|
@ -16,16 +16,21 @@ import AuthorPage, { AuthorPageProps } from '../author/[slug]/[...tab]'
|
||||||
import TopicPage, { TopicPageProps } from '../topic/[slug]/[...tab]'
|
import TopicPage, { TopicPageProps } from '../topic/[slug]/[...tab]'
|
||||||
|
|
||||||
const fetchShout = async (slug: string): Promise<Shout | undefined> => {
|
const fetchShout = async (slug: string): Promise<Shout | undefined> => {
|
||||||
|
console.debug('fetchShout called with slug:', slug)
|
||||||
if (slug.startsWith('@')) return
|
if (slug.startsWith('@')) return
|
||||||
const shoutLoader = getShout({ slug })
|
const shoutLoader = getShout({ slug })
|
||||||
const result = await shoutLoader()
|
const result = await shoutLoader()
|
||||||
|
console.debug('fetchShout result:', result)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
export const route: RouteDefinition = {
|
export const route: RouteDefinition = {
|
||||||
load: async ({ params }) => ({
|
load: async ({ params }) => {
|
||||||
article: await fetchShout(params.slug)
|
console.debug('route.load called with params:', params)
|
||||||
})
|
const article = await fetchShout(params.slug)
|
||||||
|
console.debug('route.load fetched article:', article)
|
||||||
|
return { article }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ArticlePageProps = {
|
export type ArticlePageProps = {
|
||||||
|
@ -71,11 +76,18 @@ export default function ArticlePage(props: RouteSectionProps<SlugPageProps>) {
|
||||||
function ArticlePage(props: RouteSectionProps<ArticlePageProps>) {
|
function ArticlePage(props: RouteSectionProps<ArticlePageProps>) {
|
||||||
const loc = useLocation()
|
const loc = useLocation()
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const data = createAsync(async () => props.data?.article || (await fetchShout(props.params.slug)))
|
const data = createAsync(async () => {
|
||||||
|
console.debug('createAsync fetching data with slug:', props.params.slug)
|
||||||
|
const result = props.data?.article || (await fetchShout(props.params.slug))
|
||||||
|
console.debug('createAsync fetched result:', result)
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
console.debug('onMount triggered')
|
||||||
if (gaIdentity && data()?.id) {
|
if (gaIdentity && data()?.id) {
|
||||||
try {
|
try {
|
||||||
|
console.debug('Loading GA script')
|
||||||
await loadGAScript(gaIdentity)
|
await loadGAScript(gaIdentity)
|
||||||
initGA(gaIdentity)
|
initGA(gaIdentity)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -88,6 +100,7 @@ export default function ArticlePage(props: RouteSectionProps<SlugPageProps>) {
|
||||||
on(
|
on(
|
||||||
data,
|
data,
|
||||||
(a?: Shout) => {
|
(a?: Shout) => {
|
||||||
|
console.debug('createEffect triggered with data:', a)
|
||||||
if (!a?.id) return
|
if (!a?.id) return
|
||||||
window?.gtag?.('event', 'page_view', {
|
window?.gtag?.('event', 'page_view', {
|
||||||
page_title: a.title,
|
page_title: a.title,
|
||||||
|
@ -100,17 +113,22 @@ export default function ArticlePage(props: RouteSectionProps<SlugPageProps>) {
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary fallback={() => <HttpStatusCode code={500} />}>
|
<ErrorBoundary fallback={() => {
|
||||||
|
console.error('Rendering 500 error page')
|
||||||
|
return <HttpStatusCode code={500} />
|
||||||
|
}}>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Show
|
<Show
|
||||||
when={data()?.id}
|
when={data()?.id}
|
||||||
fallback={
|
fallback={
|
||||||
<PageLayout isHeaderFixed={false} hideFooter={true} title={t('Nothing is here')}>
|
<PageLayout isHeaderFixed={false} hideFooter={true} title={t('Nothing is here')}>
|
||||||
|
{console.warn('Rendering 404 error page - no article data found')}
|
||||||
<FourOuFourView />
|
<FourOuFourView />
|
||||||
<HttpStatusCode code={404} />
|
<HttpStatusCode code={404} />
|
||||||
</PageLayout>
|
</PageLayout>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
{console.debug('Rendering article page with data:', data())}
|
||||||
<PageLayout
|
<PageLayout
|
||||||
title={`${t('Discours')}${data()?.title ? ' :: ' : ''}${data()?.title || ''}`}
|
title={`${t('Discours')}${data()?.title ? ' :: ' : ''}${data()?.title || ''}`}
|
||||||
desc={descFromBody(data()?.body || '')}
|
desc={descFromBody(data()?.body || '')}
|
||||||
|
@ -129,3 +147,4 @@ export default function ArticlePage(props: RouteSectionProps<SlugPageProps>) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return <ArticlePage {...props} />
|
return <ArticlePage {...props} />
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user