import { For, Show, createEffect, createMemo, createSignal, on } from 'solid-js' import { useAuthors } from '~/context/authors' import { useLocalize } from '../../context/localize' import { useTopics } from '../../context/topics' import { Shout, Topic } from '../../graphql/schema/core.gen' import { capitalize } from '../../utils/capitalize' import { splitToPages } from '../../utils/splitToPages' import Banner from '../Discours/Banner' import Hero from '../Discours/Hero' import { Beside } from '../Feed/Beside' import Group from '../Feed/Group' 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 { Topics } from '../Nav/Topics' import { Icon } from '../_shared/Icon' import { ArticleCardSwiper } from '../_shared/SolidSwiper/ArticleCardSwiper' import { loadShouts } from '~/lib/api' import { SHOUTS_PER_PAGE } from '~/routes/(home)' import styles from './Home.module.scss' 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[] } export const HomeView = (props: HomeViewProps) => { const { t } = useLocalize() const { topAuthors } = useAuthors() const { topTopics, randomTopic } = useTopics() const [randomTopicArticles, setRandomTopicArticles] = createSignal([]) createEffect( on( () => randomTopic(), async (topic?: Topic) => { if (topic) { const shoutsByTopicLoader = loadShouts({ filters: { topic: topic.slug, featured: true }, limit: 5, offset: 0 }) const shouts = await shoutsByTopicLoader() setRandomTopicArticles(shouts || []) } }, { defer: true } ) ) const pages = createMemo(() => splitToPages( props.featuredShouts || [], SHOUTS_PER_PAGE + CLIENT_LOAD_ARTICLES_COUNT, LOAD_MORE_PAGE_SIZE ) ) return ( 0}> SHOUTS_PER_PAGE}> {t('Top commented')}} nodate={true} />
{capitalize(randomTopic()?.title || '', true)}
} />
{(page) => ( <> )}
) }