import { For, Show, createMemo, onMount } from 'solid-js' import { useAuthors } from '~/context/authors' import { SHOUTS_PER_PAGE } from '~/context/feed' import { useLocalize } from '~/context/localize' import { useTopics } from '~/context/topics' import { Author, Shout, Topic } from '~/graphql/schema/core.gen' import { paginate } from '~/utils/paginate' import Banner from '../Discours/Banner' import Hero from '../Discours/Hero' import { Beside } from '../Feed/Beside' import { RandomTopicSwiper } from '../Feed/RandomTopicSwiper' import { Row1 } from '../Feed/Row1' import { Row2 } from '../Feed/Row2' import { Row3 } from '../Feed/Row3' import { Row5 } from '../Feed/Row5' import RowShort from '../Feed/RowShort' import { TopicsNav } from '../HeaderNav/TopicsNav' import { ArticleCardSwiper } from '../_shared/SolidSwiper/ArticleCardSwiper' export const RANDOM_TOPICS_COUNT = 12 export const RANDOM_TOPIC_SHOUTS_COUNT = 7 const CLIENT_LOAD_ARTICLES_COUNT = 29 const LOAD_MORE_PAGE_SIZE = 16 // Row1 + Row3 + Row2 + Beside (3 + 1) + Row1 + Row 2 + Row3 export interface HomeViewProps { featuredShouts: Shout[] topRatedShouts: Shout[] topMonthShouts: Shout[] topViewedShouts: Shout[] topCommentedShouts: Shout[] topics?: Topic[] } export const HomeView = (props: HomeViewProps) => { const { t } = useLocalize() const { topAuthors, addAuthors } = useAuthors() const { topTopics } = useTopics() onMount(() => { props.featuredShouts?.forEach((s: Shout) => addAuthors((s?.authors || []) as Author[])) props.topRatedShouts?.forEach((s: Shout) => addAuthors((s?.authors || []) as Author[])) }) const pages = createMemo(() => paginate(props.featuredShouts || [], SHOUTS_PER_PAGE + CLIENT_LOAD_ARTICLES_COUNT, LOAD_MORE_PAGE_SIZE) ) return ( <> 0}> SHOUTS_PER_PAGE}> {t('Top commented')}} nodate={true} /> {(page) => ( <> )} ) }