From 5c6a93c24158bc95cfd95451d883f6f59e9afacb Mon Sep 17 00:00:00 2001 From: Igor Lobanov Date: Wed, 7 Dec 2022 19:38:05 +0100 Subject: [PATCH] anchors and mainTopic fixes --- src/components/Article/FullArticle.tsx | 14 ++++++++------ src/components/Feed/Card.tsx | 6 +++--- src/stores/router.ts | 14 ++++++++++++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/components/Article/FullArticle.tsx b/src/components/Article/FullArticle.tsx index 2783e112..edc5086b 100644 --- a/src/components/Article/FullArticle.tsx +++ b/src/components/Article/FullArticle.tsx @@ -52,11 +52,13 @@ export const FullArticle = (props: ArticleProps) => { const { session } = useSession() const formattedDate = createMemo(() => formatDate(new Date(props.article.createdAt))) - const mainTopic = () => - (props.article.topics?.find((topic) => topic?.slug === props.article.mainTopic)?.title || '').replace( - ' ', - ' ' - ) + const mainTopic = createMemo( + () => + props.article.topics?.find((topic) => topic?.slug === props.article.mainTopic) || + props.article.topics[0] + ) + + const mainTopicTitle = createMemo(() => mainTopic().title.replace(' ', ' ')) onMount(() => { const windowHash = window.location.hash @@ -90,7 +92,7 @@ export const FullArticle = (props: ArticleProps) => {