flotilla/src/app/components/ContentLinkInline.svelte

28 lines
929 B
Svelte
Raw Normal View History

2024-09-24 21:12:38 +00:00
<script lang="ts">
import {displayUrl} from "@welshman/lib"
2025-02-04 03:28:29 +00:00
import {preventDefault} from "@lib/html"
2024-09-24 21:12:38 +00:00
import Icon from "@lib/components/Icon.svelte"
import Link from "@lib/components/Link.svelte"
import ContentLinkDetail from "@app/components/ContentLinkDetail.svelte"
import {pushModal} from "@app/util/modal"
2024-09-24 21:12:38 +00:00
const {value} = $props()
2024-09-24 21:12:38 +00:00
const url = value.url.toString()
const expand = () => pushModal(ContentLinkDetail, {url}, {fullscreen: true})
2024-09-24 21:12:38 +00:00
</script>
{#if url.match(/\.(jpe?g|png|gif|webp)$/)}
2024-11-18 20:51:13 +00:00
<!-- Use a real link so people can copy the href -->
2025-02-04 00:37:14 +00:00
<a href={url} class="link-content whitespace-nowrap" onclick={preventDefault(expand)}>
<Icon icon="link-round" size={3} class="inline-block" />
{displayUrl(url)}
2024-11-18 20:51:13 +00:00
</a>
{:else}
2024-10-31 17:21:05 +00:00
<Link external href={url} class="link-content whitespace-nowrap">
<Icon icon="link-round" size={3} class="inline-block" />
{displayUrl(url)}
</Link>
{/if}