articles fix

This commit is contained in:
Igor Lobanov 2022-12-07 20:49:03 +01:00
parent 5c6a93c241
commit 73ac5a1e9a
9 changed files with 16 additions and 13 deletions

View File

@ -8,7 +8,7 @@ import { loadAuthor } from '../../stores/zine/authors'
import { Loading } from '../Loading' import { Loading } from '../Loading'
export const AuthorPage = (props: PageProps) => { export const AuthorPage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.author)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.authorShouts) && Boolean(props.author))
const slug = createMemo(() => { const slug = createMemo(() => {
const { page: getPage } = useRouter() const { page: getPage } = useRouter()
@ -38,7 +38,7 @@ export const AuthorPage = (props: PageProps) => {
return ( return (
<PageWrap> <PageWrap>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<AuthorView author={props.author} shouts={props.shouts} authorSlug={slug()} /> <AuthorView author={props.author} shouts={props.authorShouts} authorSlug={slug()} />
</Show> </Show>
</PageWrap> </PageWrap>
) )

View File

@ -8,7 +8,7 @@ import { Loading } from '../Loading'
import styles from './HomePage.module.scss' import styles from './HomePage.module.scss'
export const HomePage = (props: PageProps) => { export const HomePage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.randomTopics)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.homeShouts) && Boolean(props.randomTopics))
onMount(async () => { onMount(async () => {
if (isLoaded()) { if (isLoaded()) {
@ -26,7 +26,7 @@ export const HomePage = (props: PageProps) => {
return ( return (
<PageWrap class={styles.mainContent}> <PageWrap class={styles.mainContent}>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<HomeView randomTopics={props.randomTopics} shouts={props.shouts || []} /> <HomeView randomTopics={props.randomTopics} shouts={props.homeShouts || []} />
</Show> </Show>
</PageWrap> </PageWrap>
) )

View File

@ -29,7 +29,7 @@ export const LayoutShoutsPage = (props: PageProps) => {
return page.params.layout as LayoutType return page.params.layout as LayoutType
}) })
const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false) const [isLoadMoreButtonVisible, setIsLoadMoreButtonVisible] = createSignal(false)
const { sortedLayoutShouts, loadLayoutShoutsBy } = useLayoutsStore(layout(), props.shouts) const { sortedLayoutShouts, loadLayoutShoutsBy } = useLayoutsStore(layout(), props.layoutShouts)
const sortedArticles = createMemo<Shout[]>(() => sortedLayoutShouts().get(layout()) || []) const sortedArticles = createMemo<Shout[]>(() => sortedLayoutShouts().get(layout()) || [])
const loadMoreLayout = async (kind: LayoutType) => { const loadMoreLayout = async (kind: LayoutType) => {
saveScrollPosition() saveScrollPosition()

View File

@ -8,7 +8,7 @@ import { loadTopic } from '../../stores/zine/topics'
import { Loading } from '../Loading' import { Loading } from '../Loading'
export const TopicPage = (props: PageProps) => { export const TopicPage = (props: PageProps) => {
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts) && Boolean(props.topic)) const [isLoaded, setIsLoaded] = createSignal(Boolean(props.topicShouts) && Boolean(props.topic))
const slug = createMemo(() => { const slug = createMemo(() => {
const { page: getPage } = useRouter() const { page: getPage } = useRouter()
@ -38,7 +38,7 @@ export const TopicPage = (props: PageProps) => {
return ( return (
<PageWrap> <PageWrap>
<Show when={isLoaded()} fallback={<Loading />}> <Show when={isLoaded()} fallback={<Loading />}>
<TopicView topic={props.topic} shouts={props.shouts} topicSlug={slug()} /> <TopicView topic={props.topic} shouts={props.topicShouts} topicSlug={slug()} />
</Show> </Show>
</PageWrap> </PageWrap>
) )

View File

@ -6,7 +6,10 @@ import type { LayoutType } from '../stores/zine/layouts'
export type PageProps = { export type PageProps = {
randomTopics?: Topic[] randomTopics?: Topic[]
article?: Shout article?: Shout
shouts?: Shout[] layoutShouts?: Shout[]
authorShouts?: Shout[]
topicShouts?: Shout[]
homeShouts?: Shout[]
author?: Author author?: Author
allAuthors?: Author[] allAuthors?: Author[]
topic?: Topic topic?: Topic

View File

@ -16,5 +16,5 @@ Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate'
--- ---
<Prerendered> <Prerendered>
<Root shouts={shouts} author={author} client:load /> <Root authorShouts={shouts} author={author} client:load />
</Prerendered> </Prerendered>

View File

@ -15,6 +15,6 @@ initRouter(pathname, search)
--- ---
<Prerendered> <Prerendered>
<Root shouts={shouts} layout={layout} client:load /> <Root layoutShouts={shouts} layout={layout} client:load />
</Prerendered> </Prerendered>

View File

@ -6,7 +6,7 @@ import { initRouter } from '../stores/router'
import { PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../components/Views/Home' import { PRERENDERED_ARTICLES_COUNT, RANDOM_TOPICS_COUNT } from '../components/Views/Home'
const randomTopics = await apiClient.getRandomTopics({ amount: RANDOM_TOPICS_COUNT }) const randomTopics = await apiClient.getRandomTopics({ amount: RANDOM_TOPICS_COUNT })
const articles = await apiClient.getShouts( const shouts = await apiClient.getShouts(
{ filters: { visibility: "public" }, limit: PRERENDERED_ARTICLES_COUNT }) { filters: { visibility: "public" }, limit: PRERENDERED_ARTICLES_COUNT })
const { pathname, search } = Astro.url const { pathname, search } = Astro.url
@ -16,6 +16,6 @@ Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate'
--- ---
<Prerendered> <Prerendered>
<Root randomTopics={randomTopics} shouts={articles} client:load /> <Root randomTopics={randomTopics} homeShouts={shouts} client:load />
</Prerendered> </Prerendered>

View File

@ -17,5 +17,5 @@ Astro.response.headers.set('Cache-Control', 's-maxage=1, stale-while-revalidate'
--- ---
<Prerendered> <Prerendered>
<Root shouts={shouts} topic={topic} client:load /> <Root topicShouts={shouts} topic={topic} client:load />
</Prerendered> </Prerendered>