feat: Add communities
This commit is contained in:
1 parent
5be28724b8
commit
5f674d4691
4 files changed
+32
-4
No files matched your search
@@ -17,7 +17,7 @@
|
|||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||||
import { isImage } from '$lib/ui/image.js'
|
import { isImage, isVideo } from '$lib/ui/image.js'
|
||||||
import { authData, getClient } from '$lib/lemmy.js'
|
import { authData, getClient } from '$lib/lemmy.js'
|
||||||
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
@@ -91,6 +91,13 @@
|
|||||||
loading="lazy"
|
loading="lazy"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
{:else if isVideo(postRes.post.url)}
|
||||||
|
<!-- svelte-ignore a11y-media-has-caption -->
|
||||||
|
<a href="/post/{postRes.post.id}" class="inline self-start">
|
||||||
|
<video class="rounded-md max-h-64 max-w-full" preload="metadata">
|
||||||
|
<source src={postRes.post.url} />
|
||||||
|
</video>
|
||||||
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
{#if postRes.post.body}
|
{#if postRes.post.body}
|
||||||
<p class="text-sm max-h-24 line-clamp-3">
|
<p class="text-sm max-h-24 line-clamp-3">
|
||||||
|
|||||||
+11
-2
@@ -1,2 +1,11 @@
|
|||||||
export const isImage = (url: string | undefined) =>
|
export const isImage = (url: string | undefined) => {
|
||||||
/\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(url ?? '')
|
if (!url) return false
|
||||||
|
|
||||||
|
return /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(new URL(url).pathname)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const isVideo = (url: string | undefined) => {
|
||||||
|
if (!url) return false
|
||||||
|
|
||||||
|
return new URL(url).pathname.toLowerCase().endsWith('.mp4')
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
|
||||||
|
<h1 class="font-black text-3xl">404</h1>
|
||||||
|
<p class="mx-4 md:mx-8">
|
||||||
|
It's likely that this community hasn't been federated (nobody on your
|
||||||
|
instance has subscribed to it yet.)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||||
import { isImage } from '$lib/ui/image.js'
|
import { isImage, isVideo } from '$lib/ui/image.js'
|
||||||
import { user } from '$lib/lemmy.js'
|
import { user } from '$lib/lemmy.js'
|
||||||
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
||||||
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
||||||
@@ -107,6 +107,11 @@
|
|||||||
alt={post.name}
|
alt={post.name}
|
||||||
class="rounded-md max-w-screen max-h-[80vh] mx-auto"
|
class="rounded-md max-w-screen max-h-[80vh] mx-auto"
|
||||||
/>
|
/>
|
||||||
|
{:else if isVideo(post.url)}
|
||||||
|
<!-- svelte-ignore a11y-media-has-caption -->
|
||||||
|
<video class="rounded-md max-w-screen max-h-[80vh] mx-auto">
|
||||||
|
<source src={post.url} />
|
||||||
|
</video>
|
||||||
{/if}
|
{/if}
|
||||||
{#if post.body}
|
{#if post.body}
|
||||||
<p
|
<p
|
||||||
|
|||||||
Reference in new issue
Block a user