feat: add embeds

This commit is contained in:
Xyphyn committed 2023-10-05 16:21:30 -07:00
1 parent ec72b62c0b
commit 869afbd0cb
8 files changed
+110 -48

No files matched your search

+16 -9
View File
@@ -1,20 +1,27 @@
<script lang="ts">
export let href: string
export let highlight: boolean = false
export let nowrap: boolean = false
const parseURL = (href: string) => {
<script lang="ts" context="module">
export const parseURL = (href: string) => {
try {
return new URL(href)
} catch (e) {
return undefined
}
}
$: richURL = parseURL(href)
</script>
<a {href} class="{highlight ? 'text-blue-500' : ''} hover:underline max-w-full">
<script lang="ts">
export let href: string
export let highlight: boolean = false
export let nowrap: boolean = false
$: richURL = $$slots.default ? undefined : parseURL(href)
</script>
<a
{href}
class="{highlight
? 'text-blue-500'
: ''} hover:underline max-w-full inline-flex items-center gap-1 {$$props.class}"
>
<slot name="icon" />
<slot>
<span
+3 -5
View File
@@ -137,12 +137,10 @@
{:else if post.post.url}
<PostLink
url={post.post.url}
thumbnail_url={view == 'card'
? post.post.thumbnail_url
? `${post.post.thumbnail_url}?format=webp&thumbnail=512`
: undefined
: undefined}
thumbnail_url={post.post.thumbnail_url}
nsfw={post.post.nsfw}
embed_description={post.post.embed_description}
embed_title={post.post.embed_title}
/>
{/if}
{#if post.post.body && !post.post.nsfw && view != 'compact'}
+48 -4
View File
@@ -1,14 +1,58 @@
<script lang="ts">
import Link from '$lib/components/input/Link.svelte'
import Link, { parseURL } from '$lib/components/input/Link.svelte'
import { Material } from 'mono-svelte'
import { Icon, Link as LinkIcon } from 'svelte-hero-icons'
export let url: string
export let thumbnail_url: string | undefined = undefined
export let nsfw: boolean = false
export let embed_title: string | undefined = undefined
export let embed_description: string | undefined = undefined
$: richURL = parseURL(url)
</script>
<Link href={url} highlight nowrap />
{#if thumbnail_url}
{#if embed_title}
<Material class="flex flex-row gap-4">
<div class="flex flex-col gap-2">
{#if richURL}
<Link
href={url}
class="text-slate-600 dark:text-zinc-400 inline-flex items-center gap-1 text-xs"
>
<Icon src={LinkIcon} size="12" mini slot="icon" />
{richURL.hostname}
</Link>
{/if}
<a href={url} class="font-medium text-base hover:underline">
{embed_title}
</a>
{#if embed_description}
<p
class="text-sm text-transparent bg-clip-text bg-gradient-to-b
from-slate-700 dark:from-zinc-400
via-slate-700 dark:via-zinc-400
to-slate-700/0 dark:to-zinc-400/0"
>
{embed_description.slice(0, 300)}
</p>
{/if}
</div>
{#if thumbnail_url}
<a href={url}>
<img
src={thumbnail_url}
class="rounded-lg max-w-[200px] w-full h-auto aspect-video object-cover bg-slate-200 dark:bg-zinc-800"
width={600}
height={400}
alt=""
class:blur-3xl={nsfw}
/>
</a>
{/if}
</Material>
{:else if thumbnail_url}
<Link href={url} highlight nowrap />
<a href={url}>
<img
src={thumbnail_url}
@@ -12,6 +12,7 @@
<svelte:window bind:scrollY={scroll} />
<div class="shell {$$props.class}">
<slot />
<slot
name="navbar"
class="sticky top-0 border-b border-slate-200 dark:border-zinc-900