Fix photos list and add currentPhotos store

Go from one object to two to avoid issues when using an object key
This commit is contained in:
2020-02-26 15:59:44 +01:00
parent fab89736ed
commit ba36c9a8b6
3 changed files with 50 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
<script context="module">
// Svelte
import { apiEndpoints, site, locations, currentLocation } from '../../../store'
import { apiEndpoints, site, locations, currentLocation, currentPhotos } from '../../../store'
import { stores } from '@sapper/app'
// Preload data
@@ -43,7 +43,8 @@
// Update current location
const location = $locations.find(loc => loc.slug === $page.params.location)
currentLocation.set({ location, photos })
currentLocation.set(location)
currentPhotos.set(photos)
// Define dates
const dateUpdatedFull = photos.length ? dayjs(photos[0].modified_on).format('MMM Do, YYYY') : ''
@@ -157,7 +158,11 @@
<div class="photos__view wrap">
{#each paginatedPhotos as photo, index}
<Photo {photo} index={index + 1} />
<Photo
photo={photo}
layout={layoutSetting}
index={photos.length - (photos.indexOf(photo))}
/>
{/each}
</div>