Introduce segments for blog posts and filter them
This commit is contained in:
@ -52,6 +52,7 @@ export async function getBlogListing(paginationQuery: PaginationQuery) {
|
||||
}
|
||||
})
|
||||
)
|
||||
console.log(paginationQuery);
|
||||
const filteredContents = pipe(
|
||||
sortBy<ArticleContent>(prop('date')),
|
||||
(items) => reverse(items),
|
||||
|
@ -34,6 +34,7 @@ export function filterAndCount<Item extends Record<string, any>>({
|
||||
...dropTakeParams
|
||||
}: PaginationQuery) {
|
||||
return function (items: Item[]) {
|
||||
console.log(filters);
|
||||
const filterFunction = filters
|
||||
? filterByPropContains<Item>(filters)
|
||||
: identity
|
||||
|
@ -8,6 +8,7 @@ import type { RequestHandler } from './$types'
|
||||
|
||||
export const prerender = true
|
||||
export const GET = (async ({ params }) => {
|
||||
console.log(params);
|
||||
const handledParams = params.params === 'index' ? '' : params.params
|
||||
const { page = 1, pageSize = 7, ...filters } = parseParams(handledParams)
|
||||
const paginationParams = getDropTakeFromPageParams(
|
||||
|
@ -6,9 +6,8 @@ import type { PaginationResult } from '$lib/pagination/pagination'
|
||||
export const load = (async ({ fetch, params }) => {
|
||||
const { page = 1, pageSize = 7, ...filters } = parseParams(params.params)
|
||||
const articleResponse = await fetch(
|
||||
`/articles/${params.params ? params.params : 'index'}.json`
|
||||
`/articles/segments/blog${params.params ? `/${params.params}` : ''}.json`
|
||||
).then((r) => r.json())
|
||||
|
||||
return {
|
||||
posts: articleResponse.posts as PaginationResult<ArticleContent>,
|
||||
page: Number(page),
|
||||
|
@ -6,7 +6,7 @@ import type { PaginationResult } from '$lib/pagination/pagination'
|
||||
export const load = (async ({ fetch, params }) => {
|
||||
const { page = 1, pageSize = 7, ...filters } = parseParams(params.params)
|
||||
const articleResponse = await fetch(
|
||||
`/articles/${params.params ? params.params : 'index'}.json`
|
||||
`/articles/segments/broadcasts${params.params ? `/${params.params}` : ''}.json`
|
||||
).then((r) => r.json())
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user