import { capitalize } from '../../utils' import './Full.scss' import { Icon } from '../_shared/Icon' import ArticleComment from './Comment' import { AuthorCard } from '../Author/Card' import { createMemo, createSignal, For, onMount, Show } from 'solid-js' import type { Author, Reaction, Shout } from '../../graphql/types.gen' import { t } from '../../utils/intl' import { showModal } from '../../stores/ui' import MD from './MD' import { SharePopup } from './SharePopup' import { useSession } from '../../context/session' import stylesHeader from '../Nav/Header.module.scss' import styles from '../../styles/Article.module.scss' import RatingControl from './RatingControl' import { clsx } from 'clsx' const MAX_COMMENT_LEVEL = 6 const getCommentLevel = (comment: Reaction, level = 0) => { if (comment && comment.replyTo && level < MAX_COMMENT_LEVEL) { return 0 // FIXME: getCommentLevel(commentsById[c.replyTo], level + 1) } return level } interface ArticleProps { article: Shout reactions: Reaction[] isCommentsLoading: boolean } const formatDate = (date: Date) => { return date .toLocaleDateString('ru', { month: 'long', day: 'numeric', year: 'numeric' }) .replace(' г.', '') } export const FullArticle = (props: ArticleProps) => { const { session } = useSession() const formattedDate = createMemo(() => formatDate(new Date(props.article.createdAt))) const [isSharePopupVisible, setIsSharePopupVisible] = createSignal(false) const mainTopic = () => (props.article.topics?.find((topic) => topic?.slug === props.article.mainTopic)?.title || '').replace( ' ', ' ' ) onMount(() => { const windowHash = window.location.hash if (windowHash?.length > 0) { const comments = document.querySelector(windowHash) if (comments) { window.scrollTo({ top: comments.getBoundingClientRect().top, behavior: 'smooth' }) } } }) return (