Check is location is fresh/updated
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte'
|
||||
import dayjs from 'dayjs'
|
||||
// Components
|
||||
import Image from '$components/atoms/Image.svelte'
|
||||
|
||||
export let location: any
|
||||
|
||||
const { name, slug, country, last_updated } = location
|
||||
const { settings: { limit_new }}: any = getContext('global')
|
||||
|
||||
const { name, slug, country, date_updated } = location
|
||||
const dateNowOffset = dayjs().subtract(limit_new, 'day')
|
||||
const dateLocationUpdated = dayjs(date_updated)
|
||||
const isNew = dateLocationUpdated.isAfter(dateNowOffset)
|
||||
</script>
|
||||
|
||||
<div class="location" role="listitem">
|
||||
@@ -14,5 +21,8 @@
|
||||
{name}
|
||||
</h3>
|
||||
<span class="text-label">{country.name}</span>
|
||||
{#if isNew}
|
||||
<!-- show the badge -->
|
||||
{/if}
|
||||
</a>
|
||||
</div>
|
||||
@@ -55,6 +55,7 @@
|
||||
seo_name
|
||||
seo_title
|
||||
seo_description
|
||||
limit_new
|
||||
instagram
|
||||
footer_links
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from 'svelte'
|
||||
// Components
|
||||
import Button from '$components/atoms/Button.svelte'
|
||||
import Locations from '$components/organisms/Locations.svelte'
|
||||
import Metas from '$components/Metas.svelte'
|
||||
import Button from '$components/atoms/Button.svelte'
|
||||
import PhotoCard from '$components/molecules/PhotoCard.svelte'
|
||||
import Locations from '$components/organisms/Locations.svelte'
|
||||
|
||||
export let photos: any
|
||||
|
||||
|
||||
0
src/utils/functions.ts
Normal file
0
src/utils/functions.ts
Normal file
Reference in New Issue
Block a user