aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components/topic_summary/topic_summary.svelte
blob: 8c4df4d7502be2827f0ed4a5cb8e1d26173e9e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<script lang="ts">
	import type { Topic } from '$lib/data/types';

	export let topic: Topic;

	import { _ } from 'svelte-i18n';
	import { readableTime } from '$lib/utils/readable_time';

	$: remainingTime = new Date(topic.updated_at).getTime() + topic.ttl - Date.now();
	$: remaining = readableTime(remainingTime);
</script>

<li class="h-entry" title={$_('topic.title')}>
	<span class="p-name">
		<a
			class="u-url u-uid underline text-blue-600 visited:text-purple-500"
			title={$_('topic.permalink_title')}
			href="/t/{topic.id}"
		>
			{topic.title}
		</a></span
	>
	<span class="topic-ttl"
		>({$_('topic.remaining_time', {
			values: { remaining: $_(remaining.label, { values: { count: remaining.count } }) }
		})})
	</span>
</li>