resolvers-updates

This commit is contained in:
Untone 2023-12-10 01:15:02 +03:00
parent 44af27d7a5
commit e00086ee70
8 changed files with 12 additions and 12 deletions

View File

@ -52,7 +52,7 @@ export const Comment = (props: Props) => {
actions: { showSnackbar }, actions: { showSnackbar },
} = useSnackbar() } = useSnackbar()
const isCommentAuthor = createMemo(() => props.comment.created_by?.slug === author().slug) const isCommentAuthor = createMemo(() => props.comment.created_by?.slug === author()?.slug)
const comment = createMemo(() => props.comment) const comment = createMemo(() => props.comment)
const body = createMemo(() => (comment().body || '').trim()) const body = createMemo(() => (comment().body || '').trim())

View File

@ -84,7 +84,7 @@ export const TopicCard = (props: TopicProps) => {
} }
const title = createMemo(() => const title = createMemo(() =>
capitalize(lang() == 'en' ? props.topic.slug.replace(/-/, ' ') : props.topic.title || ''), capitalize(lang() == 'en' ? props.topic.slug.replace(/-/g, ' ') : props.topic.title || ''),
) )
return ( return (

View File

@ -54,7 +54,7 @@ export const TopicBadge = (props: Props) => {
/> />
<a href={`/topic/${props.topic.slug}`} class={styles.info}> <a href={`/topic/${props.topic.slug}`} class={styles.info}>
<span class={styles.title}> <span class={styles.title}>
{lang() == 'en' ? capitalize(props.topic.slug.replace(/-/, ' ')) : props.topic.title} {lang() == 'en' ? capitalize(props.topic.slug.replace(/-/g, ' ')) : props.topic.title}
</span> </span>
<Show <Show
when={props.topic.body} when={props.topic.body}

View File

@ -147,7 +147,7 @@ export const AllTopicsView = (props: AllTopicsViewProps) => {
{(topic) => ( {(topic) => (
<div class={clsx(styles.topic, 'topic col-sm-12 col-md-8')}> <div class={clsx(styles.topic, 'topic col-sm-12 col-md-8')}>
<a href={`/topic/${topic.slug}`}> <a href={`/topic/${topic.slug}`}>
{lang() == 'en' ? capitalize(topic.slug.replace(/-/, ' ')) : topic.title} {lang() == 'en' ? capitalize(topic.slug.replace(/-/g, ' ')) : topic.title}
</a> </a>
<span class={styles.articlesCounter}>{topic.stat.shouts}</span> <span class={styles.articlesCounter}>{topic.stat.shouts}</span>
</div> </div>

View File

@ -228,7 +228,7 @@ export const FeedView = (props: Props) => {
{(topic) => ( {(topic) => (
<span class={clsx(stylesTopic.shoutTopic, styles.topic)}> <span class={clsx(stylesTopic.shoutTopic, styles.topic)}>
<a href={`/topic/${topic.slug}`}> <a href={`/topic/${topic.slug}`}>
{lang() == 'en' ? topic.slug.replace(/-/, ' ') : topic.title} {lang() == 'en' ? topic.slug.replace(/-/g, ' ') : topic.title}
</a>{' '} </a>{' '}
</span> </span>
)} )}

View File

@ -72,12 +72,12 @@ export const apiClient = {
} }
return response.data.get_topics_all return response.data.get_topics_all
}, },
getAllAuthors: async () => { getAllAuthors: async (limit: number = 50, offset: number = 0) => {
const response = await publicGraphQLClient.query(authorsAll, {}).toPromise() const response = await publicGraphQLClient.query(authorsAll, { limit, offset }).toPromise()
if (response.error) { if (response.error) {
console.debug('[graphql.client.core] get_authors_all', response.error) console.debug('[graphql.client.core] load_authors_all', response.error)
} }
return response.data.get_authors_all return response.data.load_authors_all
}, },
getAuthor: async (params: { slug?: string; author_id?: number; user?: string }): Promise<Author> => { getAuthor: async (params: { slug?: string; author_id?: number; user?: string }): Promise<Author> => {
const response = await publicGraphQLClient.query(authorBy, params).toPromise() const response = await publicGraphQLClient.query(authorBy, params).toPromise()

View File

@ -1,8 +1,8 @@
import { gql } from '@urql/core' import { gql } from '@urql/core'
export default gql` export default gql`
query AuthorsAllQuery { query AuthorsAllQuery($limit: Int, $offset: Int) {
get_authors_all { load_authors_all(limit: $limit, offset: $offset) {
id id
slug slug
name name

View File

@ -4,7 +4,7 @@ import type { PageContext } from '../renderer/types'
import { apiClient } from '../graphql/client/core' import { apiClient } from '../graphql/client/core'
export const onBeforeRender = async (_pageContext: PageContext) => { export const onBeforeRender = async (_pageContext: PageContext) => {
const allAuthors = await apiClient.getAllAuthors() const allAuthors = await apiClient.getAllAuthors() // limit 50, offset 0
const pageProps: PageProps = { allAuthors, seo: { title: '' } } const pageProps: PageProps = { allAuthors, seo: { title: '' } }