nicco.io/src/lib/components/PostAttributes.svelte

32 lines
644 B
Svelte
Raw Normal View History

2020-09-23 15:37:12 +02:00
<script>
import dj from 'dayjs'
import { readingTimeInMinutes } from '../lib/readingTime'
export let post
2020-11-11 20:08:36 +01:00
export let full = false
2020-09-23 15:37:12 +02:00
function format(date) {
return dj(date).format('MMM D, YYYY')
}
$: created = format(post.date)
$: modified = format(post.modified)
</script>
<style>
.attributes {
display: flex;
justify-content: space-between;
font-weight: 400;
margin-top: -0.125em;
}
</style>
<div class="attributes">
<div>
{created}
2020-10-04 10:55:33 +02:00
{#if full && created !== modified}<br /> <small>Last update: {modified}</small>{/if}
2020-09-23 15:37:12 +02:00
</div>
<div>~ {readingTimeInMinutes(post.content)} min</div>
</div>