Add City field to photos

Used for regions/wider locations
This commit is contained in:
2020-08-22 19:53:50 +02:00
parent 6a04e1568f
commit b990f944ca
4 changed files with 66 additions and 63 deletions

View File

@@ -1,4 +1,6 @@
<script context="module">
import mainQuery from 'utils/mainQuery'
export async function preload (page, session) {
await this.fetch(apiEndpoints.gql, {
method: 'post',
@@ -6,63 +8,7 @@
'Content-Type': 'application/json',
'Authorization': 'bearer ' + process.env.CONFIG.API_TOKEN
},
body: JSON.stringify({ query: `{
site {
data {
description
explore_globe
explore_list
photos_per_page
instagram
seo_name
seo_title_default
seo_description_default
seo_share_image { full_url }
credits_text
credits_list
newsletter_text
newsletter_subtitle
newsletter_url
}
}
continents {
data {
id
name
rotation_position
}
}
countries {
data {
id
name
slug
flag { full_url title }
continent { id name }
}
}
locations (filter: { status_eq: "published" }) {
data {
id
name
slug
region
country { id name slug }
description
close
coordinates
illu_desktop { full_url }
illu_desktop_2x { full_url }
illu_mobile { full_url }
}
}
photos (filter: { status_eq: "published" }) {
data {
created_on
location { id }
}
}
}`})
body: JSON.stringify({ query: mainQuery })
})
.then(res => res.json())
.then(res => {

View File

@@ -7,7 +7,7 @@
const fields = [
'id', 'name', 'slug', 'date', 'image.private_hash',
'location.id', 'location.name', 'location.slug', 'location.region',
'location.country.name', 'location.country.slug',
'location.country.name', 'location.country.slug', 'city',
'created_on', 'modified_on'
].join(',')
const sort = ['-created_on', 'name'].join(',')
@@ -73,7 +73,6 @@
** Pagination
*/
let photosPerPage = $site.photos_per_page
let currentIndex = photosPerPage
// Hide photos by default
photos.forEach((photo, index) => photo.hidden = (index + 1 > photosPerPage) ? true : false)
@@ -190,7 +189,7 @@
{#if photos}
<div class="photos__view wrap">
{#each paginatedPhotos as photo, index}
{#each paginatedPhotos as photo}
<Photo {photo} index={photos.length - photos.indexOf(photo)} />
{/each}
</div>