Check is location is fresh/updated

This commit is contained in:
2021-09-28 16:11:48 +02:00
parent 1883d5781f
commit a5380070a1
6 changed files with 21 additions and 3 deletions

View File

@@ -16,6 +16,7 @@
"lint": "eslint --ignore-path .gitignore ." "lint": "eslint --ignore-path .gitignore ."
}, },
"dependencies": { "dependencies": {
"dayjs": "^1.10.7",
"focus-visible": "^5.2.0", "focus-visible": "^5.2.0",
"sanitize.css": "^12.0.1" "sanitize.css": "^12.0.1"
}, },

6
pnpm-lock.yaml generated
View File

@@ -6,6 +6,7 @@ specifiers:
'@sveltejs/kit': next '@sveltejs/kit': next
'@typescript-eslint/eslint-plugin': ^4.32.0 '@typescript-eslint/eslint-plugin': ^4.32.0
'@typescript-eslint/parser': ^4.32.0 '@typescript-eslint/parser': ^4.32.0
dayjs: ^1.10.7
eslint: ^7.32.0 eslint: ^7.32.0
eslint-plugin-svelte3: ^3.2.1 eslint-plugin-svelte3: ^3.2.1
focus-visible: ^5.2.0 focus-visible: ^5.2.0
@@ -19,6 +20,7 @@ specifiers:
typescript: ^4.4.3 typescript: ^4.4.3
dependencies: dependencies:
dayjs: 1.10.7
focus-visible: 5.2.0 focus-visible: 5.2.0
motion: 10.1.0 motion: 10.1.0
sanitize.css: 12.0.1 sanitize.css: 12.0.1
@@ -494,6 +496,10 @@ packages:
which: 2.0.2 which: 2.0.2
dev: true dev: true
/dayjs/1.10.7:
resolution: {integrity: sha512-P6twpd70BcPK34K26uJ1KT3wlhpuOAPoMwJzpsIWUxHZ7wpmbdZL/hQqBDfz7hGurYSa5PhzdhDHtt319hL3ig==}
dev: false
/debug/4.3.2: /debug/4.3.2:
resolution: {integrity: sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==} resolution: {integrity: sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==}
engines: {node: '>=6.0'} engines: {node: '>=6.0'}

View File

@@ -1,10 +1,17 @@
<script lang="ts"> <script lang="ts">
import { getContext } from 'svelte'
import dayjs from 'dayjs'
// Components // Components
import Image from '$components/atoms/Image.svelte' import Image from '$components/atoms/Image.svelte'
export let location: any 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> </script>
<div class="location" role="listitem"> <div class="location" role="listitem">
@@ -14,5 +21,8 @@
{name} {name}
</h3> </h3>
<span class="text-label">{country.name}</span> <span class="text-label">{country.name}</span>
{#if isNew}
<!-- show the badge -->
{/if}
</a> </a>
</div> </div>

View File

@@ -55,6 +55,7 @@
seo_name seo_name
seo_title seo_title
seo_description seo_description
limit_new
instagram instagram
footer_links footer_links
} }

View File

@@ -1,10 +1,10 @@
<script lang="ts"> <script lang="ts">
import { getContext } from 'svelte' import { getContext } from 'svelte'
// Components // Components
import Button from '$components/atoms/Button.svelte'
import Locations from '$components/organisms/Locations.svelte'
import Metas from '$components/Metas.svelte' import Metas from '$components/Metas.svelte'
import Button from '$components/atoms/Button.svelte'
import PhotoCard from '$components/molecules/PhotoCard.svelte' import PhotoCard from '$components/molecules/PhotoCard.svelte'
import Locations from '$components/organisms/Locations.svelte'
export let photos: any export let photos: any

0
src/utils/functions.ts Normal file
View File