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 }) => {
const blogPostsResponse = await fetch(`/blog/articles/pageSize/5.json`)
export const load = (async ({ fetch }) => {
const blogPostsResponse = await fetch(`/blog/articles/pageSize/5`)
const blogPostsContent = await blogPostsResponse.json()
return {
latestPosts: blogPostsContent.posts.items,
// TODO Check if not bugged FIXME
segment: '',
}
}) satisfies LayoutLoad

View File

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