misc: basic functionality
This commit is contained in:
1 parent
c9fc488ef2
commit
83608fdaa6
12 files changed
+133
-22
No files matched your search
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<nav
|
<nav
|
||||||
class="flex top-0 z-20 flex-row gap-4 items-center mt-2 w-full h-16
|
class="flex top-0 z-20 flex-row gap-4 items-center mt-2 w-full h-16
|
||||||
max-w-7xl mx-auto px-6"
|
max-w-5xl mx-auto px-6"
|
||||||
>
|
>
|
||||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||||
<a href="/">
|
<a href="/">
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Navbar routes={$page.url.pathname.split('/').slice(2)} />
|
<Navbar routes={$page.url.pathname.split('/').slice(1)} />
|
||||||
<div class="mx-auto max-w-7xl p-4">
|
<div class="mx-auto max-w-5xl p-4">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import { lemmy } from '$lib/lemmy.js';
|
import { lemmy } from '$lib/lemmy.js';
|
||||||
import { error } from '@sveltejs/kit';
|
|
||||||
|
|
||||||
export function load({ params }) {
|
export function load({ params }) {
|
||||||
return lemmy.getCommunity({ name: params.name })
|
return lemmy.getCommunity({ name: params.name })
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { GetCommunityResponse } from 'lemmy-js-client'
|
import type { GetCommunityResponse } from 'lemmy-js-client'
|
||||||
|
|
||||||
export let data: Promise<GetCommunityResponse>
|
export let data: GetCommunityResponse
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#await data then data}
|
<div class="flex flex-col gap-4">
|
||||||
<div class="flex flex-col gap-4">
|
|
||||||
<div class="flex flex-row gap-4 items-center">
|
<div class="flex flex-row gap-4 items-center">
|
||||||
<img
|
<img
|
||||||
src={data.community_view.community.icon}
|
src={data.community_view.community.icon}
|
||||||
@@ -19,5 +18,4 @@
|
|||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
{/await}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import { redirect } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
export function load({ params }) {
|
||||||
|
throw redirect(300, `/c/${params.name}/posts`)
|
||||||
|
}
|
||||||
@@ -1,18 +1,14 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import MultiSelect from '$lib/components/MultiSelect.svelte'
|
import MultiSelect from '$lib/components/MultiSelect.svelte'
|
||||||
import type { PostResponse } from 'lemmy-js-client'
|
import Post from '../../../post/[id]/Post.svelte'
|
||||||
import Post from './Post.svelte'
|
|
||||||
|
|
||||||
export let data: any
|
export let data
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<MultiSelect options={['Community', 'idk']} selected="Community" />
|
<MultiSelect options={['Community', 'idk']} selected="Community" />
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
{#await data then data}
|
{#each data.posts as post}
|
||||||
<pre>{JSON.stringify(data, undefined, 2)}</pre>
|
|
||||||
{#each data?.posts as post}
|
|
||||||
<Post {post} />
|
<Post {post} />
|
||||||
{/each}
|
{/each}
|
||||||
{/await}
|
|
||||||
</div>
|
</div>
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
export let post: Post
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<p>{post.post.name}</p>
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import { lemmy } from '$lib/lemmy.js'
|
||||||
|
|
||||||
|
export async function load({ params }) {
|
||||||
|
return {
|
||||||
|
post: await lemmy.getPost({ id: Number(params.id) }),
|
||||||
|
comments: await lemmy.getComments({
|
||||||
|
post_id: Number(params.id),
|
||||||
|
type_: 'All',
|
||||||
|
limit: 20,
|
||||||
|
page: 1,
|
||||||
|
max_depth: 3,
|
||||||
|
saved_only: false,
|
||||||
|
sort: 'Hot',
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import MultiSelect from '$lib/components/MultiSelect.svelte'
|
||||||
|
import type { GetCommentsResponse, GetPostResponse } from 'lemmy-js-client'
|
||||||
|
|
||||||
|
export let data: { post: GetPostResponse; comments: GetCommentsResponse }
|
||||||
|
|
||||||
|
const postData = data.post.post_view
|
||||||
|
const post = postData.post
|
||||||
|
|
||||||
|
const comments = data.comments.comments
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
|
<span class="flex flex-row gap-2 text-sm opacity-70">
|
||||||
|
<a href="/">c/{postData.community.name}</a>
|
||||||
|
<span class="opacity-50">{postData.creator.name}</span>
|
||||||
|
</span>
|
||||||
|
<h1 class="font-bold text-lg">{post.name}</h1>
|
||||||
|
{#if post.thumbnail_url}
|
||||||
|
<img src={post.thumbnail_url} alt={post.name} />
|
||||||
|
{/if}
|
||||||
|
{#if post.body}
|
||||||
|
<p>{post.body}</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="mt-4 flex flex-col gap-2">
|
||||||
|
<div class="font-bold text-lg">Comments</div>
|
||||||
|
<MultiSelect
|
||||||
|
options={['hot', 'new', 'top']}
|
||||||
|
optionNames={['Hot', 'New', 'Top']}
|
||||||
|
selected="hot"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{#each comments as comment}
|
||||||
|
{comment.comment.content}
|
||||||
|
{/each}
|
||||||
File renamed without changes.
@@ -0,0 +1,66 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { GetPostResponse, PostView } from 'lemmy-js-client'
|
||||||
|
import {
|
||||||
|
ArrowDown,
|
||||||
|
ArrowUp,
|
||||||
|
ChatBubbleLeft,
|
||||||
|
ChevronDown,
|
||||||
|
ChevronUp,
|
||||||
|
Icon,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
let postRes: PostView
|
||||||
|
export { postRes as post }
|
||||||
|
|
||||||
|
const post = postRes.post
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="bg-white dark:bg-zinc-900 border dark:border-zinc-800 border-slate-200
|
||||||
|
rounded-md flex flex-col overflow-hidden max-w-xl"
|
||||||
|
>
|
||||||
|
<div class="flex flex-col gap-2 bg-white p-4 rounded-md">
|
||||||
|
<span class="flex flex-row gap-2 text-sm opacity-70">
|
||||||
|
<a href="/">c/{postRes.community.name}</a>
|
||||||
|
<span class="opacity-50">{postRes.creator.name}</span>
|
||||||
|
</span>
|
||||||
|
<h1 class="font-bold text-lg">{post.name}</h1>
|
||||||
|
{#if post.url}
|
||||||
|
<a
|
||||||
|
href={post.url}
|
||||||
|
class="text-sky-400 max-w-[24ch] overflow-hidden
|
||||||
|
whitespace-nowrap text-ellipsis text-xs hover:underline"
|
||||||
|
>
|
||||||
|
{post.url}
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
{#if post.body}
|
||||||
|
<p class="text-sm max-h-24 line-clamp-3">
|
||||||
|
{post.body}
|
||||||
|
</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="flex flex-row gap-2 p-2">
|
||||||
|
<div
|
||||||
|
class="flex flex-row items-center gap-1 rounded-md
|
||||||
|
bg-slate-100"
|
||||||
|
>
|
||||||
|
<button aria-label="Upvote" class="p-1 px-1.5">
|
||||||
|
<Icon src={ChevronUp} mini width={20} height={20} />
|
||||||
|
</button>
|
||||||
|
<span class="text-sm">{postRes.counts.score}</span>
|
||||||
|
<button aria-label="Downvote" class="p-1 px-1.5">
|
||||||
|
<Icon src={ChevronDown} mini width={20} height="20}" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a
|
||||||
|
class="flex flex-row items-center gap-2.5 p-1 px-2 rounded-md
|
||||||
|
bg-slate-100"
|
||||||
|
href="/post/{post.id}"
|
||||||
|
>
|
||||||
|
<Icon src={ChatBubbleLeft} width={16} height={16} />
|
||||||
|
<span class="text-sm">{postRes.counts.comments}</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
+1
-1
@@ -2,5 +2,5 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [sveltekit()]
|
plugins: [sveltekit()],
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user