Introduce segments for blog posts and filter them

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

View File

@ -1,6 +1,8 @@
---
layout: blog
title: How I've built my website
segments:
- blog
published: true
date: 2020-02-28T16:00:55.791Z
thumbnail: /images/uploads/DSC01202.jpg

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Custom Redox keyboard assembly
segments:
- blog
published: true
date: 2020-04-10T15:16:54.820Z
thumbnail: /images/uploads/img_20200301_171735.jpg

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Transition to Colemak keyboard layout
segments:
- blog
published: true
date: 2020-05-11T05:38:18.797Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Samsung Galaxy Buds+ Review
segments:
- blog
published: true
date: 2020-06-07T22:58:18.797Z # TODO executable line for generating date
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: I've made an RSS feed
segments:
- blog
published: true
date: 2020-06-15T15:48:18.797Z # TODO executable line for generating date
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: WebAssembly briefing
segments:
- blog
published: true
date: 2020-08-05T15:38:18.797Z # TODO executable line for generating date
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: How to deal with technical debt
segments:
- blog
published: true
date: 2020-11-08T15:57:18.797Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: I've moved my site to Netlify
segments:
- blog
published: true
date: 2020-11-20T20:35:05.230Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Guide on error handling
segments:
- blog
published: true
date: 2020-12-09T14:44:11.948Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Logging recommendations
segments:
- blog
published: true
date: 2020-12-18T14:39:53.533Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Podcast episode about Agile development
segments:
- blog
published: true
date: 2021-02-16T09:09:57.102Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Introduction to JavaScript Application testing
segments:
- blog
published: true
date: 2021-05-07T14:44:57.102Z # update date accordingly
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: How we handle the rapid growth of the project team
segments:
- blog
published: true
date: 2021-12-16T11:02:10.123Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: First Weekly
segments:
- blog
published: true
date: 2022-02-06T17:13:02.611Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: "I've started streaming - Weekly #06-2022 "
segments:
- blog
published: true
date: 2022-02-13T19:39:33.578Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: "Laptop battery got fat - Weekly #07-2022"
segments:
- blog
published: true
date: 2022-02-20T17:50:56.214Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Error handling with Either<Type>
segments:
- blog
published: true
date: 2022-02-28T11:30:54.195Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: "Second attempt @ Weekly #08-2022"
segments:
- blog
published: true
date: 2022-02-28T11:49:53.914Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: "Coming from DevBreak - Weekly #11-2022"
segments:
- blog
published: true
date: 2022-03-19T21:22:35.128Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: "Happy Easter - Weekly #15-2022"
segments:
- blog
published: true
date: 2022-04-17T08:05:05.489Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: 'Treasure hunt - Weekly #18-2022'
segments:
- blog
published: true
date: 2022-05-07T08:35:51.818Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: "Our attempt at Rusty game jam - Weekly #25-2022"
segments:
- blog
published: true
date: 2022-06-26T20:02:47.419Z
tags:

View File

@ -1,6 +1,8 @@
---
layout: blog
title: Lovely London Trip
segments:
- blog
published: true
date: 2022-11-27T19:49:09.204Z
tags:

View File

@ -1,6 +1,10 @@
---
layout: blog
title: dev - Ide to ? copy
segments:
- blog
- broadcasts
- cookbook
published: true
date: 2020-01-09T17:24:13.481Z
thumbnail: /images/uploads/screenshot.gif

View File

@ -1,6 +1,10 @@
---
layout: blog
title: dev - Ide to ?
segments:
- blog
- broadcasts
- cookbook
published: true
date: 2019-08-09T17:24:13.481Z
thumbnail: /images/uploads/screenshot.gif

View File

@ -1,6 +1,10 @@
---
layout: blog
title: dev - Anothert one
segments:
- blog
- broadcasts
- cookbook
published: true
date: 2019-11-03T11:01:32.621Z
thumbnail: /images/uploads/responzio.png

View File

@ -1,6 +1,10 @@
---
layout: blog
title: New Title
segments:
- blog
- broadcasts
- cookbook
published: true
date: 2020-05-11T05:38:18.797Z # TODO executable line for generating date
tags:

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 {

View File

@ -19,6 +19,15 @@ collections:
fields: # The fields for each document, usually in front matter
- { label: 'Layout', name: 'layout', widget: 'hidden', default: 'blog' }
- { label: 'Title', name: 'title', widget: 'string' }
- label: 'Segments'
name: 'segments'
widget: 'select'
multiple: true
options:
- { label: 'Blog', value: 'blog' }
- { label: 'Broadcasts', value: 'Broadcasts' }
- { label: 'Cookbook', value: 'cookbook' }
default: ['blog']
- {
label: 'Published',
name: 'published',