Manage displayed photos via the API
All checks were successful
continuous-integration/drone/push Build is passing

Define limits (for homepage carousel and photos per page on a place) in the site settings via a slider
This commit is contained in:
2020-03-16 13:11:58 +01:00
parent 9965c9dec3
commit 8c8ee101f2
3 changed files with 13 additions and 6 deletions

View File

@@ -1,15 +1,21 @@
<script context="module">
import { apiEndpoints } from '../utils/store'
import { site, apiEndpoints } from '../utils/store'
// Preload data
// Variables
let limit
// Preload data (photos to display)
export async function preload (page, session) {
// Load random photos
// Fields
const fields = [
'id', 'name', 'image.private_hash',
'location.id', 'location.name', 'location.slug', 'location.country.name'
]
// Random sort
const sort = '?'
const limit = 5
// Get the limit from API
site.subscribe(store => limit = store.homepage_photos_limit)
const req = await this.fetch(`${apiEndpoints.rest}/items/photos?fields=${fields.join()}&sort=${sort}&limit=${limit}`)
const photos = await req.json()
if (req.ok) {
@@ -22,7 +28,6 @@
<script>
import { onMount } from 'svelte'
import {
site,
currentLocation,
currentPhotos,
pageReady,