import { Show, createMemo, createSignal, createEffect } from 'solid-js' import type { Author, Shout, Topic } from '../../graphql/types.gen' import Row2 from '../Feed/Row2' import Row3 from '../Feed/Row3' import AuthorFull from '../Author/Full' import { t } from '../../utils/intl' import { useAuthorsStore } from '../../stores/zine/authors' import { params as paramsStore } from '../../stores/router' import { useArticlesStore } from '../../stores/zine/articles' import '../../styles/Topic.scss' import Beside from '../Feed/Beside' import { useStore } from '@nanostores/solid' type AuthorProps = { authorArticles: Shout[] author: Author } export const AuthorPage = (props: AuthorProps) => { const params = useStore(paramsStore) const { getSortedArticles: articles, getArticlesByAuthors: articlesByAuthors } = useArticlesStore({ sortedArticles: props.authorArticles }) const { getAuthorEntities: authors } = useAuthorsStore([props.author]) const author = createMemo(() => authors()[props.author.slug]) const slug = createMemo(() => author().slug) /* const slug = createMemo(() => { let slug = props?.slug if (props?.slug.startsWith('@')) slug = slug.replace('@', '') return slug }) */ const [authorTopics, setAuthorTopics] = createSignal[]>([]) createEffect(() => { if (authorTopics().length === 0 && articles().length > 0) { const r = [] as Topic[] articlesByAuthors()[slug()].forEach((a: Shout) => { a.topics.forEach((topic: Topic) => { if (!r.some((t) => t.slug === topic.slug)) r.push(topic) }) }) setAuthorTopics(r) } }, [articles()]) const title = createMemo(() => { const m = params()['by'] if (m === 'viewed') return t('Top viewed') if (m === 'rating') return t('Top rated') if (m === 'commented') return t('Top discussed') return t('Top recent') }) const setBy = (what: string) => { params()['by'] = what } return (
{t('Loading')}
}>
{`${t('Show')} `} {t('All posts')}

{title()}

0}>
) }