diff --git a/src/routes/authors.tsx b/src/routes/authors.tsx new file mode 100644 index 00000000..04762833 --- /dev/null +++ b/src/routes/authors.tsx @@ -0,0 +1,63 @@ +import { RouteDefinition, RouteLoadFuncArgs, type RouteSectionProps, createAsync } from '@solidjs/router' +import { Suspense, createEffect } from 'solid-js' +import { AllAuthors } from '~/components/Views/AllAuthors' +import { useAuthors } from '~/context/authors' +import { Author, QueryLoad_Authors_ByArgs } from '~/graphql/schema/core.gen' +import { loadAuthors } from '~/lib/api' +import { Loading } from '../components/_shared/Loading' +import { PageLayout } from '../components/_shared/PageLayout' +import { useLocalize } from '../context/localize' +import { ReactionsProvider } from '../context/reactions' + +const fetchData = async () => { + const opts: QueryLoad_Authors_ByArgs = { + by: { + after: undefined, + created_at: undefined, + last_seen: undefined, + name: undefined, + order: undefined, + slug: undefined, + stat: undefined, + topic: undefined + } + } + const topicsFetcher = loadAuthors(opts) + return await topicsFetcher() +} +const AUTHORS_PER_PAGE = 20 +export const route = { + load: (_args: RouteLoadFuncArgs) => { + const opts: QueryLoad_Authors_ByArgs = { + by: { + after: undefined, + created_at: undefined, + last_seen: undefined, + name: undefined, + order: undefined, + slug: undefined, + stat: undefined, + topic: undefined + }, + limit: AUTHORS_PER_PAGE, + offset: 0 + } + return loadAuthors(opts) + } +} satisfies RouteDefinition + +export default function AllTopicsPage(props: RouteSectionProps<{ authors: Author[] }>) { + const { t } = useLocalize() + const authors = createAsync(async () => props.data.authors || (await fetchData()) || []) + const { addAuthors } = useAuthors() + createEffect(() => addAuthors(authors() || [])) + return ( + + + }> + + + + + ) +} diff --git a/src/routes/topic/[slug].tsx b/src/routes/topic/[slug].tsx index b4bc59aa..cc8448f0 100644 --- a/src/routes/topic/[slug].tsx +++ b/src/routes/topic/[slug].tsx @@ -11,7 +11,6 @@ import { LoadShoutsOptions, Shout, Topic } from '~/graphql/schema/core.gen' import { loadShouts } from '~/lib/api' import { SHOUTS_PER_PAGE } from '../(home)' - const fetchTopicShouts = async (slug: string) => { const opts: LoadShoutsOptions = { filters: { topic: slug }, limit: SHOUTS_PER_PAGE } const shoutsLoader = loadShouts(opts) @@ -23,7 +22,9 @@ export const route = { } export const TopicPage = (props: RouteSectionProps<{ articles: Shout[] }>) => { - const articles = createAsync(async () => props.data.articles || (await fetchTopicShouts(props.params.slug)) || []) + const articles = createAsync( + async () => props.data.articles || (await fetchTopicShouts(props.params.slug)) || [] + ) const { topicEntities } = useTopics() const { t } = useLocalize() const topic = createMemo(() => topicEntities?.()[props.params.slug]) @@ -52,7 +53,11 @@ export const TopicPage = (props: RouteSectionProps<{ articles: Shout[] }>) => { cover={topic()?.pic || ''} > - +