fix build

This commit is contained in:
Michal Vanko 2023-02-21 20:22:09 +01:00
parent 6969858727
commit 3b80a0602f
6 changed files with 16 additions and 15 deletions

View File

@ -1,12 +1,13 @@
import { error } from "@sveltejs/kit";
import fm from "front-matter";
import { readFile } from "fs";
import { parseField } from "$lib/markdown/parse-markdown";
import { promisify } from "util";
import { error } from '@sveltejs/kit'
import fm from 'front-matter'
import { readFile } from 'fs'
import { parseField } from '$lib/markdown/parse-markdown'
import { promisify } from 'util'
export interface ArticleAttributes {
slug: string
layout: string
segments: string[]
title: string
published: boolean
date: string

View File

@ -1,6 +1,6 @@
<script lang="ts">
import { format } from 'date-fns'
import type { ArticleContent } from '$lib/content/articleContentListing'
import type { ArticlePreviewAttributes } from '$lib/articleContent/articleContentListing'
import SvgIcon from './SvgIcon.svelte'
import {
boldClass,
@ -22,7 +22,7 @@
licenceText,
} from './Footer.css'
export let latestPosts: ArticleContent[]
export let latestPosts: ArticlePreviewAttributes[]
</script>
<footer class="site-footer navigation-theme {siteFooterClass}">
@ -61,7 +61,7 @@
<ul class={listUlClass}>
{#each latestPosts as post}
<li class={listLiClass}>
<a rel="prefetch" href="/blog/{post.slug}">
<a rel="prefetch" href="/{post.segments[0]}/{post.slug}">
<span>{post.title}</span>
<time class="date {dateClass}" datetime={post.date}>
- {format(new Date(post.date), 'do MMM, yyyy')}

View File

@ -1,9 +1,9 @@
import { splitEvery } from 'ramda'
import { init, splitEvery } from 'ramda'
export function parseParams(params: string) {
const splittedParams = params.split('/')
let splittedParams = params.split('/')
if (splittedParams.length % 2 !== 0) {
return []
splittedParams = init(splittedParams)
}
const splits = splitEvery(2, splittedParams)
return Object.fromEntries(splits)

View File

@ -18,7 +18,9 @@ export function dropAndTake<Item>({ offset = 0, limit = Infinity }) {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function filterByPropContains<Item extends Record<string, any>>(filters: Record<string, string>) {
export function filterByPropContains<Item extends Record<string, any>>(
filters: Record<string, string>
) {
return function (items: Item[]) {
return items.filter((item) => {
return Object.entries(filters).every(([fieldName, value]) =>
@ -34,7 +36,6 @@ 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,7 +8,6 @@ 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

@ -1,5 +1,5 @@
import { getBlogListing } from '$lib/articleContent/articleContentListing'
import { Feed } from 'feed'
import { getBlogListing } from './blog/content'
export async function getFeed() {
const feed = new Feed({