diff --git a/client/src/pages/article.tsx b/client/src/pages/article.tsx index 38d37c5..f63fc33 100644 --- a/client/src/pages/article.tsx +++ b/client/src/pages/article.tsx @@ -1,5 +1,5 @@ import { useQuery } from "@tanstack/react-query"; -import { useParams, Link } from "wouter"; +import { useParams, Link, useLocation } from "wouter"; import { type Article } from "@shared/schema"; import { format } from "date-fns"; import { de } from "date-fns/locale"; @@ -101,10 +101,18 @@ export default function ArticlePage() { const { slug } = useParams<{ slug: string }>(); const isMobile = useIsMobile(); + const [, navigate] = useLocation(); + const { data: article, isLoading, error } = useQuery
({ queryKey: ["/api/articles", slug], }); + // Kartice (horoskop, recept) samo napotijo naprej — tudi pri kliku znotraj strani. + const targetUrl = (article as any)?.targetUrl as string | undefined; + useEffect(() => { + if (targetUrl) navigate(targetUrl, { replace: true }); + }, [targetUrl, navigate]); + const articleUrl = article ? `${window.location.origin}/article/${article.slug}` : ""; const articleImage = article?.coverImage ? (article.coverImage.startsWith("http") ? article.coverImage : `${window.location.origin}${article.coverImage}`) @@ -262,6 +270,8 @@ export default function ArticlePage() { + if (targetUrl) return null; + if (isLoading) { return (