2024-07-13 09:36:23 +00:00
|
|
|
import { Params, RouteSectionProps, createAsync } from '@solidjs/router'
|
2024-09-24 11:56:16 +00:00
|
|
|
import { Show, onMount } from 'solid-js'
|
2024-07-21 02:17:42 +00:00
|
|
|
import { TopicsNav } from '~/components/TopicsNav'
|
2024-07-04 07:51:15 +00:00
|
|
|
import { Expo } from '~/components/Views/Expo'
|
|
|
|
import { PageLayout } from '~/components/_shared/PageLayout'
|
2024-09-16 12:57:00 +00:00
|
|
|
import { EXPO_LAYOUTS, SHOUTS_PER_PAGE } from '~/context/feed'
|
2024-07-04 07:51:15 +00:00
|
|
|
import { useLocalize } from '~/context/localize'
|
|
|
|
import { loadShouts } from '~/graphql/api/public'
|
2024-07-03 21:25:03 +00:00
|
|
|
import { LoadShoutsOptions, Shout } from '~/graphql/schema/core.gen'
|
|
|
|
import { LayoutType } from '~/types/common'
|
|
|
|
|
|
|
|
const fetchExpoShouts = async (layouts: string[]) => {
|
|
|
|
const result = await loadShouts({
|
|
|
|
filters: { layouts },
|
|
|
|
limit: SHOUTS_PER_PAGE,
|
|
|
|
offset: 0
|
|
|
|
} as LoadShoutsOptions)
|
|
|
|
return result || []
|
|
|
|
}
|
|
|
|
|
|
|
|
export const route = {
|
|
|
|
load: async ({ params }: { params: Params }) => {
|
2024-09-16 12:57:00 +00:00
|
|
|
const layouts = params.layout ? [params.layout] : EXPO_LAYOUTS
|
2024-07-03 21:25:03 +00:00
|
|
|
const shoutsLoader = await fetchExpoShouts(layouts)
|
|
|
|
return (await shoutsLoader()) as Shout[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-05 17:23:07 +00:00
|
|
|
export default (props: RouteSectionProps<Shout[]>) => {
|
2024-07-03 21:25:03 +00:00
|
|
|
const { t } = useLocalize()
|
|
|
|
const shouts = createAsync(
|
|
|
|
async () =>
|
2024-09-16 12:57:00 +00:00
|
|
|
props.data || (await fetchExpoShouts(props.params.layout ? [props.params.layout] : EXPO_LAYOUTS))
|
2024-07-03 21:25:03 +00:00
|
|
|
)
|
2024-09-24 11:56:16 +00:00
|
|
|
|
|
|
|
const getTitle = (l: string) => {
|
|
|
|
switch (l) {
|
2024-07-03 21:25:03 +00:00
|
|
|
case 'audio': {
|
|
|
|
return t('Audio')
|
|
|
|
}
|
|
|
|
case 'video': {
|
|
|
|
return t('Video')
|
|
|
|
}
|
|
|
|
case 'image': {
|
|
|
|
return t('Artworks')
|
|
|
|
}
|
|
|
|
case 'literature': {
|
|
|
|
return t('Literature')
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return t('Art')
|
|
|
|
}
|
|
|
|
}
|
2024-09-24 11:56:16 +00:00
|
|
|
}
|
2024-07-03 21:25:03 +00:00
|
|
|
|
2024-09-24 11:56:16 +00:00
|
|
|
onMount(() => {
|
|
|
|
document.title = getTitle(props.params.layout || '')
|
|
|
|
})
|
2024-07-03 21:25:03 +00:00
|
|
|
|
|
|
|
return (
|
2024-09-24 11:56:16 +00:00
|
|
|
<PageLayout
|
|
|
|
withPadding={true}
|
|
|
|
zeroBottomPadding={true}
|
|
|
|
title={`${t('Discours')} :: ${getTitle(props.params.layout || '')}`}
|
|
|
|
>
|
2024-07-09 09:13:13 +00:00
|
|
|
<TopicsNav />
|
2024-09-16 12:57:00 +00:00
|
|
|
<Show when={shouts()} keyed>
|
2024-09-24 11:56:16 +00:00
|
|
|
{(sss) => <Expo shouts={sss} layout={props.params.layout as LayoutType} />}
|
2024-09-16 12:57:00 +00:00
|
|
|
</Show>
|
2024-07-03 21:25:03 +00:00
|
|
|
</PageLayout>
|
|
|
|
)
|
|
|
|
}
|