Add relative date from latest photo on Location page
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { page } from '$app/stores'
|
||||
import dayjs from 'dayjs'
|
||||
import advancedFormat from 'dayjs/plugin/advancedFormat'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||
import { getAssetUrl } from '$utils/helpers'
|
||||
// Components
|
||||
import Button from '$components/atoms/Button.svelte'
|
||||
@@ -12,6 +13,7 @@
|
||||
export let photos: any
|
||||
|
||||
dayjs.extend(advancedFormat)
|
||||
dayjs.extend(relativeTime)
|
||||
|
||||
const { params } = $page
|
||||
let descriptionEl: HTMLElement
|
||||
@@ -54,7 +56,11 @@
|
||||
{/each}
|
||||
</p>
|
||||
·
|
||||
<p class="text-label">Updated [10] days ago</p>
|
||||
<p class="text-label" title={dayjs(photos[0].date_created).format('DD/MM/YYYY')}>
|
||||
Updated <time datetime={dayjs(photos[0].date_created).format('YYYY-MM-DD')}>
|
||||
{dayjs().to(dayjs(photos[0].date_created))}
|
||||
</time>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="ctas">
|
||||
@@ -141,11 +147,12 @@
|
||||
photo (filter: { location: { slug: { _eq: "${location}" } }}) {
|
||||
title
|
||||
slug
|
||||
date_taken
|
||||
image {
|
||||
id
|
||||
title
|
||||
}
|
||||
date_taken
|
||||
date_created
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
Reference in New Issue
Block a user