Fix loading articles on layout

This commit is contained in:
Michal Vanko 2023-01-31 19:27:36 +01:00
parent dad51ddb33
commit fd719937d9
2 changed files with 4 additions and 6 deletions

View File

@ -1,12 +1,10 @@
import type { LayoutLoad } from './$types'; import type { LayoutLoad } from './$types'
export const load = (async ({ fetch, url }) => { export const load = (async ({ fetch }) => {
const blogPostsResponse = await fetch(`/blog/articles/pageSize/5.json`) const blogPostsResponse = await fetch(`/blog/articles/pageSize/5`)
const blogPostsContent = await blogPostsResponse.json() const blogPostsContent = await blogPostsResponse.json()
return { return {
latestPosts: blogPostsContent.posts.items, latestPosts: blogPostsContent.posts.items,
// TODO Check if not bugged FIXME
segment: '',
} }
}) satisfies LayoutLoad }) satisfies LayoutLoad

View File

@ -55,7 +55,7 @@ export async function getBlogListing(paginationQuery: PaginationQuery) {
const filteredContents = pipe( const filteredContents = pipe(
sortBy<PostContent>(prop('date')), sortBy<PostContent>(prop('date')),
(items) => reverse(items), (items) => reverse(items),
filter<typeof contents[0]>((article) => article.published), filter<(typeof contents)[0]>((article) => article.published),
filterAndCount(paginationQuery) filterAndCount(paginationQuery)
)(contents) )(contents)