From b6788c7fc1f80b9bb577b81ba7c54b1dc3fbbe1d Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Wed, 20 Sep 2023 16:53:36 -0700 Subject: [PATCH] feat: use background clips instead of a weird absolute whatever --- src/lib/components/input/Link.svelte | 28 ++++++++++++-- src/lib/components/lemmy/post/Post.svelte | 45 ++++++++++------------- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/src/lib/components/input/Link.svelte b/src/lib/components/input/Link.svelte index 098d1e36..2b9e7af9 100644 --- a/src/lib/components/input/Link.svelte +++ b/src/lib/components/input/Link.svelte @@ -3,17 +3,39 @@ export let highlight: boolean = false export let nowrap: boolean = false + const parseURL = (href: string) => { + try { + return new URL(href) + } catch (e) { + return undefined + } + } + + $: richURL = parseURL(href) - {href} + {#if richURL} + + {richURL.protocol}// + + + {richURL.hostname} + + + {richURL.pathname} + + {:else} + {href} + {/if} diff --git a/src/lib/components/lemmy/post/Post.svelte b/src/lib/components/lemmy/post/Post.svelte index e0baa51e..6a2558e2 100644 --- a/src/lib/components/lemmy/post/Post.svelte +++ b/src/lib/components/lemmy/post/Post.svelte @@ -39,9 +39,9 @@
-
+
- {#if $userSettings.view == 'card'} - {#if isImage(post.post.url)} + {#if isImage(post.post.url)} + {#if view == 'card'} - {:else if post.post.url} - {/if} + {:else if post.post.url} + {/if} {#if post.post.body && !post.post.nsfw && (view == 'list' || view == 'card')}
- {#if post.post.body.length > (view == 'list' ? 200 : 600)} -
- {/if}
{/if}
{#if ($userSettings.view == 'list' || $userSettings.view == 'compact') && (post.post.thumbnail_url || isImage(post.post.url))} -
+
{#if !$userSettings.expandImages || (post.post.thumbnail_url && !isImage(post.post.url))}