merged.
This commit is contained in:
parent
25aaecf360
commit
57baccccf2
|
@ -130,8 +130,8 @@ export const AuthorView = (props: Props) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const ogImage = props.author?.userpic
|
const ogImage = props.author?.pic
|
||||||
? getImageUrl(props.author.userpic, { width: 1200 })
|
? getImageUrl(props.author.pic, { width: 1200 })
|
||||||
: getImageUrl('production/image/logo_image.png')
|
: getImageUrl('production/image/logo_image.png')
|
||||||
const description = getDescription(props.author?.bio)
|
const description = getDescription(props.author?.bio)
|
||||||
const ogTitle = props.author?.name
|
const ogTitle = props.author?.name
|
||||||
|
|
|
@ -3,17 +3,12 @@ import { clsx } from 'clsx'
|
||||||
import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from 'solid-js'
|
import { createEffect, createMemo, createSignal, For, on, onCleanup, onMount, Show } from 'solid-js'
|
||||||
|
|
||||||
import { useLocalize } from '../../../context/localize'
|
import { useLocalize } from '../../../context/localize'
|
||||||
import {
|
import { apiClient } from '../../../graphql/client/core'
|
||||||
LoadRandomTopShoutsParams,
|
import { LoadShoutsFilters, LoadShoutsOptions, Shout } from '../../../graphql/schema/core.gen'
|
||||||
LoadShoutsFilters,
|
|
||||||
LoadShoutsOptions,
|
|
||||||
Shout,
|
|
||||||
} from '../../../graphql/schema/core.gen'
|
|
||||||
import { LayoutType } from '../../../pages/types'
|
import { LayoutType } from '../../../pages/types'
|
||||||
import { router } from '../../../stores/router'
|
import { router } from '../../../stores/router'
|
||||||
import { loadShouts, resetSortedArticles, useArticlesStore } from '../../../stores/zine/articles'
|
import { loadShouts, resetSortedArticles, useArticlesStore } from '../../../stores/zine/articles'
|
||||||
import { apiClient } from '../../../utils/apiClient'
|
import { getUnixtime } from '../../../utils/getServerDate'
|
||||||
import { getServerDate } from '../../../utils/getServerDate'
|
|
||||||
import { restoreScrollPosition, saveScrollPosition } from '../../../utils/scroll'
|
import { restoreScrollPosition, saveScrollPosition } from '../../../utils/scroll'
|
||||||
import { splitToPages } from '../../../utils/splitToPages'
|
import { splitToPages } from '../../../utils/splitToPages'
|
||||||
import { Button } from '../../_shared/Button'
|
import { Button } from '../../_shared/Button'
|
||||||
|
@ -48,10 +43,11 @@ export const Expo = (props: Props) => {
|
||||||
const getLoadShoutsFilters = (filters: LoadShoutsFilters = {}): LoadShoutsFilters => {
|
const getLoadShoutsFilters = (filters: LoadShoutsFilters = {}): LoadShoutsFilters => {
|
||||||
const result = { ...filters }
|
const result = { ...filters }
|
||||||
|
|
||||||
|
filters.layouts = []
|
||||||
if (props.layout) {
|
if (props.layout) {
|
||||||
filters.layout = props.layout
|
filters.layouts.push(props.layout)
|
||||||
} else {
|
} else {
|
||||||
filters.excludeLayout = 'article'
|
filters.layouts.push('article')
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -64,8 +60,8 @@ export const Expo = (props: Props) => {
|
||||||
offset: sortedArticles().length,
|
offset: sortedArticles().length,
|
||||||
}
|
}
|
||||||
|
|
||||||
options.filters = getLayout()
|
options.filters = props.layout
|
||||||
? { layouts: [getLayout()] }
|
? { layouts: [props.layout] }
|
||||||
: { layouts: ['audio', 'video', 'image', 'literature'] }
|
: { layouts: ['audio', 'video', 'image', 'literature'] }
|
||||||
|
|
||||||
const { hasMore } = await loadShouts(options)
|
const { hasMore } = await loadShouts(options)
|
||||||
|
@ -79,27 +75,27 @@ export const Expo = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadRandomTopArticles = async () => {
|
const loadRandomTopArticles = async () => {
|
||||||
const params: LoadRandomTopShoutsParams = {
|
const options: LoadShoutsOptions = {
|
||||||
filters: getLoadShoutsFilters(),
|
filters: getLoadShoutsFilters(),
|
||||||
limit: 10,
|
limit: 10,
|
||||||
fromRandomCount: 100,
|
random_limit: 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await apiClient.getRandomTopShouts(params)
|
const result = await apiClient.getRandomTopShouts({ options })
|
||||||
setRandomTopArticles(result)
|
setRandomTopArticles(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadRandomTopMonthArticles = async () => {
|
const loadRandomTopMonthArticles = async () => {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const fromDate = getServerDate(new Date(now.setMonth(now.getMonth() - 1)))
|
const after = getUnixtime(new Date(now.setMonth(now.getMonth() - 1)))
|
||||||
|
|
||||||
const params: LoadRandomTopShoutsParams = {
|
const options: LoadShoutsOptions = {
|
||||||
filters: getLoadShoutsFilters({ fromDate }),
|
filters: getLoadShoutsFilters({ after }),
|
||||||
limit: 10,
|
limit: 10,
|
||||||
fromRandomCount: 10,
|
random_limit: 10,
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await apiClient.getRandomTopShouts(params)
|
const result = await apiClient.getRandomTopShouts({ options })
|
||||||
setRandomTopMonthArticles(result)
|
setRandomTopMonthArticles(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,11 +167,11 @@ export const Expo = (props: Props) => {
|
||||||
<span class={clsx('linkReplacement')}>{t('Literature')}</span>
|
<span class={clsx('linkReplacement')}>{t('Literature')}</span>
|
||||||
</ConditionalWrapper>
|
</ConditionalWrapper>
|
||||||
</li>
|
</li>
|
||||||
<li class={clsx({ 'view-switcher__item--selected': getLayout() === 'audio' })}>
|
<li class={clsx({ 'view-switcher__item--selected': props.layout === 'audio' })}>
|
||||||
<ConditionalWrapper
|
<ConditionalWrapper
|
||||||
condition={getLayout() !== 'audio'}
|
condition={props.layout !== 'audio'}
|
||||||
wrapper={(children) => (
|
wrapper={(children) => (
|
||||||
<a href={getPagePath(router, 'expoLayout', { layout: 'audio' })}>{children}</a>
|
<a href={getPagePath(router, 'expo', { layout: 'audio' })}>{children}</a>
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span class={clsx('linkReplacement')}>{t('Music')}</span>
|
<span class={clsx('linkReplacement')}>{t('Music')}</span>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Author, LoadShoutsOptions, Reaction, Shout } from '../../graphql/schema/core.gen'
|
import type { Author, LoadShoutsOptions, Reaction, Shout } from '../../../graphql/schema/core.gen'
|
||||||
|
|
||||||
import { getPagePath } from '@nanostores/router'
|
import { getPagePath } from '@nanostores/router'
|
||||||
import { Meta } from '@solidjs/meta'
|
import { Meta } from '@solidjs/meta'
|
||||||
|
@ -7,11 +7,11 @@ import { createEffect, createSignal, For, on, onMount, Show } from 'solid-js'
|
||||||
|
|
||||||
import { useLocalize } from '../../../context/localize'
|
import { useLocalize } from '../../../context/localize'
|
||||||
import { useReactions } from '../../../context/reactions'
|
import { useReactions } from '../../../context/reactions'
|
||||||
|
import { apiClient } from '../../../graphql/client/core'
|
||||||
import { router, useRouter } from '../../../stores/router'
|
import { router, useRouter } from '../../../stores/router'
|
||||||
import { useArticlesStore, resetSortedArticles } from '../../../stores/zine/articles'
|
import { useArticlesStore, resetSortedArticles } from '../../../stores/zine/articles'
|
||||||
import { useTopAuthorsStore } from '../../../stores/zine/topAuthors'
|
import { useTopAuthorsStore } from '../../../stores/zine/topAuthors'
|
||||||
import { useTopicsStore } from '../../../stores/zine/topics'
|
import { useTopicsStore } from '../../../stores/zine/topics'
|
||||||
import { apiClient } from '../../../utils/apiClient'
|
|
||||||
import { getImageUrl } from '../../../utils/getImageUrl'
|
import { getImageUrl } from '../../../utils/getImageUrl'
|
||||||
import { Icon } from '../../_shared/Icon'
|
import { Icon } from '../../_shared/Icon'
|
||||||
import { Loading } from '../../_shared/Loading'
|
import { Loading } from '../../_shared/Loading'
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export { Feed } from './Feed'
|
export { FeedView as Feed } from './Feed'
|
||||||
|
|
|
@ -11,6 +11,7 @@ import type {
|
||||||
Result,
|
Result,
|
||||||
QueryLoad_Authors_ByArgs,
|
QueryLoad_Authors_ByArgs,
|
||||||
QueryLoad_Shouts_SearchArgs,
|
QueryLoad_Shouts_SearchArgs,
|
||||||
|
QueryLoad_Shouts_Random_TopArgs,
|
||||||
} from '../schema/core.gen'
|
} from '../schema/core.gen'
|
||||||
|
|
||||||
import { createGraphQLClient } from '../createGraphQLClient'
|
import { createGraphQLClient } from '../createGraphQLClient'
|
||||||
|
@ -27,7 +28,9 @@ import shoutLoad from '../query/core/article-load'
|
||||||
import shoutsLoadBy from '../query/core/articles-load-by'
|
import shoutsLoadBy from '../query/core/articles-load-by'
|
||||||
import draftsLoad from '../query/core/articles-load-drafts'
|
import draftsLoad from '../query/core/articles-load-drafts'
|
||||||
import myFeed from '../query/core/articles-load-feed'
|
import myFeed from '../query/core/articles-load-feed'
|
||||||
|
import loadShoutsTopRandom from '../query/core/articles-load-random-top'
|
||||||
import shoutsLoadSearch from '../query/core/articles-load-search'
|
import shoutsLoadSearch from '../query/core/articles-load-search'
|
||||||
|
import loadShoutsUnrated from '../query/core/articles-load-unrated'
|
||||||
import authorBy from '../query/core/author-by'
|
import authorBy from '../query/core/author-by'
|
||||||
import authorFollowers from '../query/core/author-followers'
|
import authorFollowers from '../query/core/author-followers'
|
||||||
import authorId from '../query/core/author-id'
|
import authorId from '../query/core/author-id'
|
||||||
|
@ -47,6 +50,24 @@ export const apiClient = {
|
||||||
private: null,
|
private: null,
|
||||||
connect: (token: string) => (apiClient.private = createGraphQLClient('core', token)), // NOTE: use it after token appears
|
connect: (token: string) => (apiClient.private = createGraphQLClient('core', token)), // NOTE: use it after token appears
|
||||||
|
|
||||||
|
getRandomTopShouts: async (params: QueryLoad_Shouts_Random_TopArgs) => {
|
||||||
|
const response = await publicGraphQLClient.query(loadShoutsTopRandom, params).toPromise()
|
||||||
|
if (!response.data) {
|
||||||
|
console.error('[graphql.core] getRandomTopShouts error', response.error)
|
||||||
|
}
|
||||||
|
return response.data.load_shouts_top_random
|
||||||
|
},
|
||||||
|
|
||||||
|
getUnratedShouts: async (limit = 50, offset = 0) => {
|
||||||
|
const response = await apiClient.private.query(loadShoutsUnrated, { limit, offset }).toPromise()
|
||||||
|
|
||||||
|
if (!response.data) {
|
||||||
|
console.error('[graphql.core] getUnratedShouts error', response.error)
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.data.load_shouts_unrated
|
||||||
|
},
|
||||||
|
|
||||||
getRandomTopics: async ({ amount }: { amount: number }) => {
|
getRandomTopics: async ({ amount }: { amount: number }) => {
|
||||||
const response = await publicGraphQLClient.query(topicsRandomQuery, { amount }).toPromise()
|
const response = await publicGraphQLClient.query(topicsRandomQuery, { amount }).toPromise()
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default gql`
|
||||||
layout
|
layout
|
||||||
slug
|
slug
|
||||||
cover
|
cover
|
||||||
# community
|
# cover_caption
|
||||||
main_topic
|
main_topic
|
||||||
topics {
|
topics {
|
||||||
# id
|
# id
|
||||||
|
|
|
@ -2,18 +2,17 @@ import { gql } from '@urql/core'
|
||||||
|
|
||||||
export default gql`
|
export default gql`
|
||||||
query LoadRandomTopShoutsQuery($params: LoadRandomTopShoutsParams) {
|
query LoadRandomTopShoutsQuery($params: LoadRandomTopShoutsParams) {
|
||||||
loadRandomTopShouts(params: $params) {
|
load_shouts_top_random(params: $params) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
lead
|
# lead
|
||||||
description
|
description
|
||||||
subtitle
|
subtitle
|
||||||
slug
|
slug
|
||||||
layout
|
layout
|
||||||
cover
|
cover
|
||||||
lead
|
cover_caption
|
||||||
# community
|
main_topic
|
||||||
mainTopic
|
|
||||||
topics {
|
topics {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
@ -29,12 +28,12 @@ export default gql`
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
slug
|
slug
|
||||||
userpic
|
pic
|
||||||
createdAt
|
created_at
|
||||||
bio
|
bio
|
||||||
}
|
}
|
||||||
createdAt
|
created_at
|
||||||
publishedAt
|
published_at
|
||||||
stat {
|
stat {
|
||||||
viewed
|
viewed
|
||||||
reacted
|
reacted
|
|
@ -5,15 +5,15 @@ export default gql`
|
||||||
loadUnratedShouts(limit: $limit) {
|
loadUnratedShouts(limit: $limit) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
lead
|
# lead
|
||||||
description
|
description
|
||||||
subtitle
|
subtitle
|
||||||
slug
|
slug
|
||||||
layout
|
layout
|
||||||
cover
|
cover
|
||||||
lead
|
cover_caption
|
||||||
# community
|
# community
|
||||||
mainTopic
|
main_topic
|
||||||
topics {
|
topics {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
@ -29,12 +29,12 @@ export default gql`
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
slug
|
slug
|
||||||
userpic
|
pic
|
||||||
createdAt
|
created_at
|
||||||
bio
|
bio
|
||||||
}
|
}
|
||||||
createdAt
|
created_at
|
||||||
publishedAt
|
published_at
|
||||||
stat {
|
stat {
|
||||||
viewed
|
viewed
|
||||||
reacted
|
reacted
|
|
@ -2,3 +2,7 @@ export const getServerDate = (date: Date): string => {
|
||||||
// 2023-12-31
|
// 2023-12-31
|
||||||
return date.toISOString().slice(0, 10)
|
return date.toISOString().slice(0, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getUnixtime = (date: Date): number => {
|
||||||
|
return Math.floor(date.getTime() / 1000)
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Shout } from '../graphql/types.gen'
|
import { Shout } from '../graphql/schema/core.gen'
|
||||||
|
|
||||||
const MAX_DESCRIPTION_LENGTH = 150
|
const MAX_DESCRIPTION_LENGTH = 150
|
||||||
export const getDescription = (body: string): string => {
|
export const getDescription = (body: string): string => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user