2024-10-24 21:38:36 +02:00
|
|
|
<script lang="ts">
|
|
|
|
|
import type { NewsMessage } from "$lib/api";
|
|
|
|
|
import {
|
|
|
|
|
Card,
|
|
|
|
|
CardBody,
|
|
|
|
|
CardFooter,
|
|
|
|
|
CardText,
|
|
|
|
|
} from "@sveltestrap/sveltestrap";
|
|
|
|
|
import { DateTime } from "luxon";
|
2024-10-25 03:35:50 +02:00
|
|
|
import { marked } from "marked";
|
2024-10-24 21:38:36 +02:00
|
|
|
|
|
|
|
|
export let message: NewsMessage;
|
|
|
|
|
|
2024-10-25 03:35:50 +02:00
|
|
|
$: content = marked.parse(message.content, { breaks: true });
|
|
|
|
|
|
2024-10-24 21:38:36 +02:00
|
|
|
$: postedAt = DateTime.fromISO(message.posted_at).toLocaleString(
|
|
|
|
|
DateTime.DATETIME_MED,
|
|
|
|
|
);
|
|
|
|
|
$: editedAt = message.edited_at
|
|
|
|
|
? DateTime.fromISO(message.edited_at).toLocaleString(DateTime.DATETIME_MED)
|
|
|
|
|
: null;
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<Card>
|
|
|
|
|
<CardBody>
|
2024-10-25 03:35:50 +02:00
|
|
|
<CardText>{@html content}</CardText>
|
2024-10-24 21:38:36 +02:00
|
|
|
</CardBody>
|
|
|
|
|
<CardFooter>
|
|
|
|
|
From {message.author} • Posted {postedAt}
|
|
|
|
|
{#if editedAt}
|
|
|
|
|
<p class="text-muted">(edited {editedAt})</p>
|
|
|
|
|
{/if}
|
|
|
|
|
</CardFooter>
|
|
|
|
|
</Card>
|