Tabs to spaces and code cleaning

This commit is contained in:
2020-02-27 23:08:13 +01:00
parent b5369b66a8
commit a73d9ff71c
7 changed files with 248 additions and 243 deletions

View File

@@ -1,6 +1,11 @@
<script context="module">
// Svelte
import { apiEndpoints, site, locations, currentLocation, currentPhotos } from '../../../store'
import {
apiEndpoints,
site,
locations,
currentLocation,
currentPhotos
} from '../../../store'
import { stores } from '@sapper/app'
// Preload data
@@ -8,7 +13,7 @@
// Load photos
const req = await this.fetch(`${apiEndpoints.rest}/items/photos?fields=id,name,date,slug,image.*,location.*,location.country.*,created_on,modified_on&filter[location.slug][rlike]=%${page.params.location}%&limit=-1&sort=-created_on,name`)
const photos = await req.json()
if (req.status === 200) {
if (req.ok) {
return { photos: photos.data }
}
this.error(404, 'Not found')
@@ -47,10 +52,11 @@
currentPhotos.set(photos)
// Define dates
const dateUpdatedFull = photos.length ? dayjs(photos[0].modified_on).format('MMM Do, YYYY') : ''
const dateUpdatedDatetime = photos.length ? dayjs(photos[0].modified_on).format('YYYY-MM-DDThh:mm:ss') : ''
const dateUpdatedRelative = photos.length ? dayjs().to(dayjs(photos[0].modified_on)) : ''
const lastUpdated = photos.length ? (dayjs(photos[0].modified_on).isBefore(dayjs().subtract(1, 'M'))) ? dateUpdatedFull : dateUpdatedRelative : ''
$: latestPhoto = photos[0]
$: dateUpdatedFull = latestPhoto ? dayjs(latestPhoto.modified_on).format('MMM Do, YYYY') : ''
$: dateUpdatedDatetime = latestPhoto ?dayjs(latestPhoto.modified_on).format('YYYY-MM-DDThh:mm:ss') : ''
$: dateUpdatedRelative = latestPhoto ?dayjs().to(dayjs(latestPhoto.modified_on)) : ''
$: lastUpdated = latestPhoto ? (dayjs(latestPhoto.modified_on).isBefore(dayjs().subtract(1, 'M'))) ? dateUpdatedFull : dateUpdatedRelatives : ''
/*
@@ -156,6 +162,7 @@
</aside>
</div>
{#if photos.length}
<div class="photos__view wrap">
{#each paginatedPhotos as photo, index}
<Photo
@@ -192,6 +199,7 @@
</div>
{/if}
</section>
{/if}
</section>
<Footer />