2022-09-13 08:05:11 +00:00
|
|
|
import { Show, createMemo } from 'solid-js'
|
2022-09-13 09:59:04 +00:00
|
|
|
import type { Author, Shout } from '../../graphql/types.gen'
|
2022-09-09 11:53:35 +00:00
|
|
|
import Row2 from '../Feed/Row2'
|
|
|
|
import Row3 from '../Feed/Row3'
|
2022-09-13 09:59:04 +00:00
|
|
|
import Beside from '../Feed/Beside'
|
2022-09-09 11:53:35 +00:00
|
|
|
import AuthorFull from '../Author/Full'
|
|
|
|
import { t } from '../../utils/intl'
|
|
|
|
import { useAuthorsStore } from '../../stores/zine/authors'
|
2022-09-13 08:05:11 +00:00
|
|
|
import { params } from '../../stores/router'
|
2022-09-09 11:53:35 +00:00
|
|
|
import { useArticlesStore } from '../../stores/zine/articles'
|
|
|
|
|
|
|
|
import '../../styles/Topic.scss'
|
2022-09-09 13:30:25 +00:00
|
|
|
import { useStore } from '@nanostores/solid'
|
2022-09-13 08:05:11 +00:00
|
|
|
import { useTopicsStore } from '../../stores/zine/topics'
|
2022-09-09 11:53:35 +00:00
|
|
|
|
|
|
|
type AuthorProps = {
|
|
|
|
authorArticles: Shout[]
|
|
|
|
author: Author
|
|
|
|
}
|
|
|
|
|
|
|
|
export const AuthorPage = (props: AuthorProps) => {
|
2022-09-13 09:59:04 +00:00
|
|
|
const { getSortedArticles: articles, getArticlesByAuthor } = useArticlesStore({
|
2022-09-09 11:53:35 +00:00
|
|
|
sortedArticles: props.authorArticles
|
|
|
|
})
|
2022-09-13 09:59:04 +00:00
|
|
|
const { getAuthorEntities: authors } = useAuthorsStore({ authors: [props.author] })
|
|
|
|
const { getTopicsByAuthor } = useTopicsStore()
|
|
|
|
|
2022-09-09 11:53:35 +00:00
|
|
|
const author = createMemo(() => authors()[props.author.slug])
|
2022-09-13 09:59:04 +00:00
|
|
|
const args = useStore(params)
|
|
|
|
|
|
|
|
//const slug = createMemo(() => author().slug)
|
|
|
|
/*
|
|
|
|
const slug = createMemo<string>(() => {
|
|
|
|
let slug = props?.slug
|
|
|
|
if (props?.slug.startsWith('@')) slug = slug.replace('@', '')
|
|
|
|
return slug
|
2022-09-09 11:53:35 +00:00
|
|
|
})
|
2022-09-13 09:59:04 +00:00
|
|
|
*/
|
2022-09-13 08:05:11 +00:00
|
|
|
|
2022-09-09 11:53:35 +00:00
|
|
|
const title = createMemo(() => {
|
2022-09-13 08:05:11 +00:00
|
|
|
const m = args()['by']
|
2022-09-09 11:53:35 +00:00
|
|
|
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')
|
|
|
|
})
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div class="container author-page">
|
|
|
|
<Show when={author()} fallback={<div class="center">{t('Loading')}</div>}>
|
|
|
|
<AuthorFull author={author()} />
|
|
|
|
<div class="row group__controls">
|
|
|
|
<div class="col-md-8">
|
|
|
|
<ul class="view-switcher">
|
2022-09-13 08:05:11 +00:00
|
|
|
<li classList={{ selected: !args()['by'] || args()['by'] === 'recent' }}>
|
|
|
|
<button type="button" onClick={() => (args()['by'] = 'recent')}>
|
2022-09-09 11:53:35 +00:00
|
|
|
{t('Recent')}
|
|
|
|
</button>
|
|
|
|
</li>
|
2022-09-13 08:05:11 +00:00
|
|
|
<li classList={{ selected: args()['by'] === 'rating' }}>
|
|
|
|
<button type="button" onClick={() => (args()['by'] = 'rating')}>
|
2022-09-09 11:53:35 +00:00
|
|
|
{t('Popular')}
|
|
|
|
</button>
|
|
|
|
</li>
|
2022-09-13 08:05:11 +00:00
|
|
|
<li classList={{ selected: args()['by'] === 'viewed' }}>
|
|
|
|
<button type="button" onClick={() => (args()['by'] = 'viewed')}>
|
2022-09-09 11:53:35 +00:00
|
|
|
{t('Views')}
|
|
|
|
</button>
|
|
|
|
</li>
|
2022-09-13 08:05:11 +00:00
|
|
|
<li classList={{ selected: args()['by'] === 'commented' }}>
|
|
|
|
<button type="button" onClick={() => (args()['by'] = 'commented')}>
|
2022-09-09 11:53:35 +00:00
|
|
|
{t('Discussing')}
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
|
|
<div class="mode-switcher">
|
|
|
|
{`${t('Show')} `}
|
|
|
|
<span class="mode-switcher__control">{t('All posts')}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="floor">
|
|
|
|
<h3 class="col-12">{title()}</h3>
|
|
|
|
<div class="row">
|
|
|
|
<Show when={articles()?.length > 0}>
|
|
|
|
<Beside
|
|
|
|
title={t('Topics which supported by author')}
|
2022-09-13 09:59:04 +00:00
|
|
|
values={getTopicsByAuthor()[author().slug].slice(0, 5)}
|
2022-09-09 11:53:35 +00:00
|
|
|
beside={articles()[0]}
|
|
|
|
wrapper={'topic'}
|
|
|
|
topicShortDescription={true}
|
|
|
|
/>
|
|
|
|
<Row3 articles={articles().slice(1, 4)} />
|
|
|
|
<Row2 articles={articles().slice(4, 6)} />
|
|
|
|
<Row3 articles={articles().slice(10, 13)} />
|
|
|
|
<Row3 articles={articles().slice(13, 16)} />
|
|
|
|
</Show>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Show>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|