This commit is contained in:
Timothy Jaeryang Baek 2025-11-28 02:44:36 -05:00
parent 15dc607779
commit 6ee50770cd
2 changed files with 13 additions and 10 deletions

View file

@ -1,4 +1,6 @@
<script lang="ts">
import { decodeString } from '$lib/utils';
export let id;
export let title: string = 'N/A';
@ -15,6 +17,14 @@
return domain;
}
const getDisplayTitle = (title: string) => {
if (!title) return 'N/A';
if (title.length > 30) {
return title.slice(0, 15) + '...' + title.slice(-10);
}
return title;
};
// Helper function to check if text is a URL and return the domain
function formattedTitle(title: string): string {
if (title.startsWith('http')) {
@ -23,14 +33,6 @@
return title;
}
const getDisplayTitle = (title: string) => {
if (!title) return 'N/A';
if (title.length > 30) {
return title.slice(0, 15) + '...' + title.slice(-10);
}
return title;
};
</script>
{#if title !== 'N/A'}
@ -41,7 +43,7 @@
}}
>
<span class="line-clamp-1">
{getDisplayTitle(formattedTitle(decodeURIComponent(title)))}
{getDisplayTitle(formattedTitle(decodeString(title)))}
</span>
</button>
{/if}

View file

@ -1,5 +1,6 @@
<script lang="ts">
import { LinkPreview } from 'bits-ui';
import { decodeString } from '$lib/utils';
import Source from './Source.svelte';
export let id;
@ -50,7 +51,7 @@
}}
>
<span class="line-clamp-1">
{getDisplayTitle(formattedTitle(decodeURIComponent(sourceIds[token.ids[0] - 1])))}
{getDisplayTitle(formattedTitle(decodeString(sourceIds[token.ids[0] - 1])))}
<span class="dark:text-white/50 text-black/50">+{(token?.ids ?? []).length - 1}</span>
</span>
</button>