Introduce segments for blog posts and filter them

This commit is contained in:
2023-02-15 22:40:37 +01:00
parent f156d4dacc
commit dac3e13520
33 changed files with 84 additions and 11 deletions

View File

@ -52,6 +52,7 @@ export async function getBlogListing(paginationQuery: PaginationQuery) {
}
})
)
console.log(paginationQuery);
const filteredContents = pipe(
sortBy<ArticleContent>(prop('date')),
(items) => reverse(items),

View File

@ -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

View File

@ -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(

View File

@ -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),

View File

@ -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 {