2024-09-24 21:12:38 +00:00
|
|
|
<script lang="ts">
|
2026-04-04 11:18:29 +00:00
|
|
|
import {displayUrl} from "@welshman/lib"
|
|
|
|
|
import {getTagValue} from "@welshman/util"
|
2026-01-12 18:12:47 +00:00
|
|
|
import {preventDefault, stopPropagation} from "@lib/html"
|
2025-09-10 22:26:39 +00:00
|
|
|
import LinkRound from "@assets/icons/link-round.svg?dataurl"
|
2024-09-24 21:12:38 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2024-10-18 00:10:11 +00:00
|
|
|
import ContentLinkDetail from "@app/components/ContentLinkDetail.svelte"
|
2026-04-04 11:18:29 +00:00
|
|
|
import ContentLinkUrl from "@app/components/ContentLinkUrl.svelte"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {pushModal} from "@app/modal"
|
2026-06-08 22:33:38 +00:00
|
|
|
import {IMAGE_CONTENT_TYPES} from "@app/content"
|
2024-09-24 21:12:38 +00:00
|
|
|
|
2026-01-12 18:12:47 +00:00
|
|
|
const {value, event} = $props()
|
2024-09-24 21:12:38 +00:00
|
|
|
|
|
|
|
|
const url = value.url.toString()
|
2026-02-13 23:37:17 +00:00
|
|
|
const fileType = getTagValue("file-type", event.tags) || ""
|
2024-10-18 00:10:11 +00:00
|
|
|
|
2026-01-12 18:12:47 +00:00
|
|
|
const expand = () => pushModal(ContentLinkDetail, {value, event}, {fullscreen: true})
|
2024-09-24 21:12:38 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-02-13 23:37:17 +00:00
|
|
|
{#if url.match(/\.(jpe?g|png|gif|webp)$/) || IMAGE_CONTENT_TYPES.includes(fileType)}
|
2024-11-18 20:51:13 +00:00
|
|
|
<!-- Use a real link so people can copy the href -->
|
2026-01-13 21:16:57 +00:00
|
|
|
<a
|
|
|
|
|
href={url}
|
|
|
|
|
class="link-content whitespace-nowrap"
|
|
|
|
|
onclick={stopPropagation(preventDefault(expand))}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={LinkRound} size={3} class="inline-block" />
|
2024-10-18 00:10:11 +00:00
|
|
|
{displayUrl(url)}
|
2024-11-18 20:51:13 +00:00
|
|
|
</a>
|
2024-10-18 00:10:11 +00:00
|
|
|
{:else}
|
2026-04-04 11:18:29 +00:00
|
|
|
<ContentLinkUrl {url} class="link-content whitespace-nowrap" />
|
2024-10-18 00:10:11 +00:00
|
|
|
{/if}
|