diff --git a/src/hooks.server.ts b/src/hooks.server.ts
index d4599e5e..03b23a70 100644
--- a/src/hooks.server.ts
+++ b/src/hooks.server.ts
@@ -1,4 +1,5 @@
import { instance_url } from '$lib/lemmy.js'
+import { error } from '@sveltejs/kit'
export async function handle({ event, resolve }) {
// annoying hack to fix lemmy's CORS
@@ -12,13 +13,18 @@ export async function handle({ event, resolve }) {
event.request.headers.delete('origin')
event.request.headers.delete('host')
- const data = await fetch(`https://${instance}/${url.toString()}`, {
- method: event.request.method,
- body: event.request.body,
- headers: event.request.headers,
- })
+ try {
+ const data = await fetch(`https://${instance}/${url.toString()}`, {
+ method: event.request.method,
+ body: event.request.body,
+ headers: event.request.headers,
+ })
- return new Response(JSON.stringify(await data.json()))
+ return new Response(JSON.stringify(await data.json()))
+ } catch (err) {
+ console.error(err)
+ throw error(500, `The proxy failed to fetch from ${instance}.`)
+ }
}
const response = await resolve(event)
diff --git a/src/lib/components/Card.svelte b/src/lib/components/Card.svelte
new file mode 100644
index 00000000..074e23be
--- /dev/null
+++ b/src/lib/components/Card.svelte
@@ -0,0 +1,7 @@
+
+
+
diff --git a/src/lib/components/FormattedNumber.svelte b/src/lib/components/FormattedNumber.svelte
new file mode 100644
index 00000000..b66d590e
--- /dev/null
+++ b/src/lib/components/FormattedNumber.svelte
@@ -0,0 +1,9 @@
+
+
+{Intl.NumberFormat(locale, options).format(number)}
diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte
new file mode 100644
index 00000000..e5089473
--- /dev/null
+++ b/src/routes/+error.svelte
@@ -0,0 +1,8 @@
+
+
+
+
{$page.status}
+
{JSON.stringify($page.error)}
+
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts
index 810c1abd..103a9ed9 100644
--- a/src/routes/+page.server.ts
+++ b/src/routes/+page.server.ts
@@ -8,10 +8,13 @@ export function load({ url, cookies }) {
const listingType: ListingType =
(url.searchParams.get('type') as ListingType) || 'Local'
- return getClient(cookies.get('instance_url')).getPosts({
- limit: 40,
- page: page,
- sort: sort,
- type_: listingType,
- })
+ return {
+ posts: getClient(cookies.get('instance_url')).getPosts({
+ limit: 40,
+ page: page,
+ sort: sort,
+ type_: listingType,
+ }),
+ site: getClient(cookies.get('instance_url')).getSite({}),
+ }
}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index f58e5e7f..00f429f9 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -2,60 +2,109 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import Button from '$lib/components/Button.svelte'
+ import Card from '$lib/components/Card.svelte'
import Link from '$lib/components/Link.svelte'
import MultiSelect from '$lib/components/MultiSelect.svelte'
+ import {
+ Calendar,
+ ChatBubbleLeftEllipsis,
+ ChatBubbleOvalLeftEllipsis,
+ Icon,
+ Newspaper,
+ PencilSquare,
+ UserGroup,
+ } from 'svelte-hero-icons'
+ import Avatar from './post/[id]/Avatar.svelte'
import Post from './post/[id]/Post.svelte'
+ import FormattedNumber from '$lib/components/FormattedNumber.svelte'
+ import Markdown from '$lib/components/markdown/Markdown.svelte'
+ import RelativeDate from '$lib/components/RelativeDate.svelte'
export let data
-
-
-
{
- const url = $page.url
- url.searchParams.set('type', e.detail)
- url.searchParams.delete('page')
- goto(url, {
- invalidateAll: true,
- })
- }}
- />
- {
- const url = $page.url
- url.searchParams.set('sort', e.detail)
- url.searchParams.delete('page')
- goto(url, {
- invalidateAll: true,
- })
- }}
- />
+
+
+
+ {
+ const url = $page.url
+ url.searchParams.set('type', e.detail)
+ url.searchParams.delete('page')
+ goto(url, {
+ invalidateAll: true,
+ })
+ }}
+ />
+ {
+ const url = $page.url
+ url.searchParams.set('sort', e.detail)
+ url.searchParams.delete('page')
+ goto(url, {
+ invalidateAll: true,
+ })
+ }}
+ />
+
+
+
+ {#each data.posts.posts as post}
+
+ {/each}
+
+
+
+
+ Next
+
+
-
-
- {#each data.posts as post}
-
- {/each}
-
-
-
-
- Next
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {data.site.site_view.site.name}
+
+
diff --git a/src/routes/post/[id]/+page.svelte b/src/routes/post/[id]/+page.svelte
index 3e51539e..95330edf 100644
--- a/src/routes/post/[id]/+page.svelte
+++ b/src/routes/post/[id]/+page.svelte
@@ -10,6 +10,7 @@
import Comments from './Comments.svelte'
import SvelteMarkdown from 'svelte-markdown'
import CommunityLink from '$lib/components/CommunityLink.svelte'
+ import { isImage } from '$lib/ui/image.js'
export let data: { post: GetPostResponse; comments: GetCommentsResponse }
@@ -101,9 +102,9 @@
{post.url}
{/if}
- {#if post.thumbnail_url}
+ {#if isImage(post.url)}

diff --git a/src/routes/post/[id]/Comment.svelte b/src/routes/post/[id]/Comment.svelte
index 5076e1bf..3a1f6598 100644
--- a/src/routes/post/[id]/Comment.svelte
+++ b/src/routes/post/[id]/Comment.svelte
@@ -13,7 +13,9 @@
-
+
+
+ {#if open}
+
+
+
+ Collapse
+ {:else}
+
+ Expand
+ {#if node.children.length > 0}
+ +{node.children.length}
+ {/if}
+ {/if}
+
-
+
{Intl.NumberFormat('en', { notation: 'compact' }).format(
postRes.counts.comments
diff --git a/src/style/app.css b/src/style/app.css
index d1a04ba4..d17ee02c 100644
--- a/src/style/app.css
+++ b/src/style/app.css
@@ -25,3 +25,7 @@ pre {
@apply bg-slate-100 p-2 rounded-md m-2 max-w-full whitespace-pre-wrap
border-slate-200 border dark:bg-zinc-900 dark:border-zinc-800 text-sm;
}
+
+ol {
+ @apply list-decimal;
+}
diff --git a/tailwind.config.js b/tailwind.config.js
index 001e62f9..a3491510 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -2,7 +2,16 @@
export default {
content: ['src/**/*.{js,ts,svelte,html}'],
theme: {
- extend: {},
+ extend: {
+ animation: {
+ 'pop-in': 'pop-in 0.25s ease-out forwards'
+ },
+ keyframes: {
+ 'pop-in': {
+ '0%, 100%': { transform: 'translateX(8px)', opacity: 0 }
+ }
+ }
+ },
},
plugins: [],
}