feat: add embeds to post pages
This commit is contained in:
1 parent
3c6f6c3b5d
commit
399eb9c1fb
3 files changed
+16
-20
No files matched your search
@@ -27,7 +27,7 @@
|
|||||||
export let type: IframeType = 'none'
|
export let type: IframeType = 'none'
|
||||||
export let thumbnail: string | undefined = undefined
|
export let thumbnail: string | undefined = undefined
|
||||||
export let url: string
|
export let url: string
|
||||||
let opened = !$userSettings.embeds.clickToView
|
export let opened = !$userSettings.embeds.clickToView
|
||||||
|
|
||||||
const urlToEmbed = (inputUrl: string) => {
|
const urlToEmbed = (inputUrl: string) => {
|
||||||
if (type == 'youtube') {
|
if (type == 'youtube') {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
export let view: 'card' | 'cozy' | 'list' | 'compact' = 'cozy'
|
||||||
export let post: Post
|
export let post: Post
|
||||||
export let type: MediaType = 'none'
|
export let type: MediaType = 'none'
|
||||||
|
export let opened: boolean | undefined = undefined
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if type == 'image'}
|
{#if type == 'image'}
|
||||||
@@ -92,7 +93,12 @@
|
|||||||
<p class="text-base">Go to the post to view this video.</p>
|
<p class="text-base">Go to the post to view this video.</p>
|
||||||
</a>
|
</a>
|
||||||
{:else if type == 'iframe' && (view == 'cozy' || view == 'card') && post.url}
|
{:else if type == 'iframe' && (view == 'cozy' || view == 'card') && post.url}
|
||||||
<PostIframe thumbnail={post.thumbnail_url} type="youtube" url={post.url} />
|
<PostIframe
|
||||||
|
thumbnail={post.thumbnail_url}
|
||||||
|
type="youtube"
|
||||||
|
url={post.url}
|
||||||
|
{opened}
|
||||||
|
/>
|
||||||
{:else if type == 'embed' && post.url}
|
{:else if type == 'embed' && post.url}
|
||||||
<PostLink
|
<PostLink
|
||||||
url={post.url}
|
url={post.url}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
import { feature } from '$lib/version.js'
|
import { feature } from '$lib/version.js'
|
||||||
import { publishedToDate } from '$lib/components/util/date.js'
|
import { publishedToDate } from '$lib/components/util/date.js'
|
||||||
|
import PostMedia from '$lib/components/lemmy/post/media/PostMedia.svelte'
|
||||||
|
import { mediaType } from '$lib/components/lemmy/post/helpers.js'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -178,25 +180,11 @@
|
|||||||
<h1 class="font-bold text-lg">
|
<h1 class="font-bold text-lg">
|
||||||
<Markdown source={post.post_view.post.name} inline />
|
<Markdown source={post.post_view.post.name} inline />
|
||||||
</h1>
|
</h1>
|
||||||
{#if isImage(post.post_view.post.url)}
|
<PostMedia
|
||||||
<img
|
type={mediaType(post.post_view.post)}
|
||||||
src={post.post_view.post.url}
|
post={post.post_view.post}
|
||||||
alt={post.post_view.post.name}
|
opened
|
||||||
class="rounded-md max-w-screen max-h-[80svh] mx-auto"
|
|
||||||
/>
|
/>
|
||||||
{:else if isVideo(post.post_view.post.url)}
|
|
||||||
<!-- svelte-ignore a11y-media-has-caption -->
|
|
||||||
<video class="rounded-md max-w-screen max-h-[80svh] mx-auto" controls>
|
|
||||||
<source src={post.post_view.post.url} />
|
|
||||||
</video>
|
|
||||||
{:else if post.post_view.post.url}
|
|
||||||
<PostLink
|
|
||||||
url={post.post_view.post.url}
|
|
||||||
embed_description={post.post_view.post.embed_description}
|
|
||||||
embed_title={post.post_view.post.embed_title}
|
|
||||||
thumbnail_url={post.post_view.post.thumbnail_url}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
{#if post.post_view.post.body}
|
{#if post.post_view.post.body}
|
||||||
<div
|
<div
|
||||||
class="text-sm text-slate-800 dark:text-zinc-300 rounded-md leading-[22px]"
|
class="text-sm text-slate-800 dark:text-zinc-300 rounded-md leading-[22px]"
|
||||||
@@ -319,6 +307,7 @@
|
|||||||
nodes={buildCommentsTree(data.comments.comments)}
|
nodes={buildCommentsTree(data.comments.comments)}
|
||||||
isParent={true}
|
isParent={true}
|
||||||
/>
|
/>
|
||||||
|
{#if post.post_view.counts.comments > 5}
|
||||||
<EndPlaceholder>
|
<EndPlaceholder>
|
||||||
You've viewed {post.post_view.counts.comments} comments.
|
You've viewed {post.post_view.counts.comments} comments.
|
||||||
|
|
||||||
@@ -331,4 +320,5 @@
|
|||||||
Scroll to top
|
Scroll to top
|
||||||
</Button>
|
</Button>
|
||||||
</EndPlaceholder>
|
</EndPlaceholder>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user