feat: make search more like regular posts thanks to directus
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Damillora 2024-12-03 00:31:29 +07:00
parent 9050f39911
commit f198ec4e40

View File

@ -2,12 +2,13 @@
import { page } from '$app/stores';
import { browser } from '$app/environment';
import { Container, Hero, Index, SearchCard } from '@damillora/plachta';
import { Container, Hero, Index, Post, PostCard } from '@damillora/plachta';
import { onMount } from 'svelte';
import { search } from '$lib/content/searchApi';
import { afterNavigate } from '$app/navigation';
import { searchPost } from '$lib/content/contentApi.js';
import dayjs from 'dayjs';
let { data } = $props();
let posts: any[] = $state([]);
@ -64,9 +65,20 @@
<Hero background="/images/default-feature.jpg" />
<Container>
<Index>
<h1>Search results for: {url.searchParams.get('q')}</h1>
</Index>
<Index>
{#each posts as post}
<SearchCard title={post.title} url={post.url} excerpt={post.excerpt} />
<PostCard
title={post.title}
authors={post.authors}
primary_tag={post.category}
date={dayjs(post.date_published).format('DD MMM YYYY')}
excerpt={post.excerpt}
feature_image={post.feature_image ?? '/images/default-feature.jpg'}
url={post.url}
/>
{/each}
</Index>
<div bind:this={footer}></div>