added search

This commit is contained in:
Clément Le Bihan
2024-05-05 19:35:53 +02:00
parent 6336bb144d
commit 55443045aa
4 changed files with 27 additions and 14 deletions

View File

@@ -87,15 +87,14 @@
{/if}
{#if order !== "default"}
<div class="font-light text-sm text-slate-500">
<div class="font-light text-sm text-slate-500 flex gap-2">
<span>{post.feed.name}</span> |
{#if post.authors?.length}
{#each post.authors as author}
<div class="author">
<div class="flex gap-1 items-center">
<QuillPenLine />
<span>{author}</span>
</div>
|
</div> |
{/each}
{/if}
<Time

View File

@@ -25,14 +25,12 @@ export async function register(email: string, username: string, password: string
return j.token as string;
}
export async function getPosts(token?: string) {
const opts = {
export async function getPosts(token: string) {
const r = await fetch(env.API_URL + '/entries', {
headers: {
Authorization: `Bearer ${token}`
}
}
const r = await fetch(env.API_URL + '/entries', token ? opts : undefined);
});
const j = await r.json();
console.log(j);
return j as Post[];
}

View File

@@ -60,10 +60,11 @@ const posts: Post[] = [
}
];
export async function load() {
return {
posts: await getPosts(),
export async function load({ cookies }) {
const token = cookies.get("token");
return {
posts: await getPosts(token),
feeds
};
};
}

View File

@@ -6,7 +6,10 @@
Skeleton,
ImagePlaceholder,
Avatar,
Button,
P,
Search,
MultiSelect,
} from "flowbite-svelte";
import List from "$lib/posts/list.svelte";
import { CalendarWeekSolid } from "flowbite-svelte-icons";
@@ -35,12 +38,24 @@
dateStr,
};
});
let selected: string[] = [];
let countries = [
{ value: "us", name: "United States" },
{ value: "ca", name: "Canada" },
{ value: "fr", name: "France" },
{ value: "jp", name: "Japan" },
{ value: "en", name: "England" },
];
</script>
<MultiSelect items={countries} bind:value={selected} size="lg" />
<Search>
<Button>Search</Button>
</Search>
<main>
<Timeline order="vertical" class="max-w-3xl">
{#each displayPosts as post}
<TimelineItem title={post.title} date={post.dateStr} post={post}>
<TimelineItem title={post.title} date={post.dateStr} {post}>
<svelte:fragment slot="icon">
<span
class="flex absolute -start-3 justify-center items-center w-6 h-6 bg-primary-200 rounded-full ring-8 ring-white dark:ring-gray-900 dark:bg-primary-900"