sanifae/src/lib/components/PostList.svelte

35 lines
1.2 KiB
Svelte
Raw Normal View History

2023-02-12 01:53:13 -05:00
<script>
import Post from '$lib/components/Post.svelte';
2023-02-12 12:06:19 -05:00
import Button from '$lib/components/Button.svelte';
import {setLocation} from '$lib/util.js';
2023-02-12 01:53:13 -05:00
export let data;
</script>
2023-02-12 12:06:19 -05:00
<p>
2023-03-08 18:56:28 -05:00
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','hot')}}>Hot</Button>
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','rating')}}>Top</Button>
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','time')}}>Recent</Button>
2023-02-12 12:06:19 -05:00
</p>
2023-02-12 01:53:13 -05:00
{#if data && data.postJson && data.postJson.data}
{#each data.postJson.data as post}
<Post
success={post.success}
username={post.username}
content={post.content}
upvotes={post.upvotes}
downvotes={post.downvotes}
id={post.id}
isAuthor={post.isAuthor}
2023-02-12 12:06:19 -05:00
time={post.time}
2023-02-12 01:53:13 -05:00
></Post>
{/each}
{/if}
<p>
2023-03-06 02:26:57 -05:00
{#if data.id > 0}
<Button clickFunc={() => { window.location.search = setLocation(window.location,'page',((data.id)-1)) }}>Previous page</Button>
{/if}
2023-02-12 12:06:19 -05:00
<Button clickFunc={() => { window.location.search = setLocation(window.location,'page',((data.id)+1)) }}>Next page</Button>
2023-02-12 01:53:13 -05:00
</p>