[chore] Switch rest of page endpoints
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
import dayjs from 'dayjs'
|
||||
import relativeTime from 'dayjs/plugin/relativeTime.js'
|
||||
import { getAssetUrlKey } from '$utils/helpers'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { DURATION } from '$utils/contants'
|
||||
// Components
|
||||
import Metas from '$components/Metas.svelte'
|
||||
@@ -348,75 +349,4 @@
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</PageTransition>
|
||||
|
||||
|
||||
<script context="module" lang="ts">
|
||||
import { fetchAPI } from '$utils/api'
|
||||
|
||||
/** @type {import('@sveltejs/kit').Load} */
|
||||
export async function load ({ url, params, fetch, session, stuff }) {
|
||||
const { location } = params
|
||||
|
||||
const res = await fetchAPI(`
|
||||
query {
|
||||
location (
|
||||
filter: {
|
||||
slug: { _eq: "${location}" },
|
||||
status: { _eq: "published" },
|
||||
}
|
||||
) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
description
|
||||
date_updated
|
||||
illustration_desktop { id }
|
||||
illustration_desktop_2x { id }
|
||||
illustration_mobile { id }
|
||||
credits {
|
||||
credit_id {
|
||||
name
|
||||
website
|
||||
}
|
||||
}
|
||||
country { name }
|
||||
has_poster
|
||||
}
|
||||
|
||||
photos: photo (
|
||||
filter: {
|
||||
location: { slug: { _eq: "${location}" }}
|
||||
},
|
||||
sort: "-date_created",
|
||||
limit: ${import.meta.env.VITE_LIST_AMOUNT},
|
||||
page: 1,
|
||||
) {
|
||||
title
|
||||
slug
|
||||
city
|
||||
image {
|
||||
id
|
||||
title
|
||||
}
|
||||
date_taken
|
||||
date_created
|
||||
}
|
||||
|
||||
total_published: photo_aggregated (filter: { location: { slug: { _eq: "${location}" }}}) {
|
||||
count { location }
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
const { data } = res
|
||||
|
||||
return {
|
||||
props: {
|
||||
location: data.location[0],
|
||||
photos: data.photos,
|
||||
totalPhotos: data.photos.length ? data.total_published[0].count.location : 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</PageTransition>
|
||||
Reference in New Issue
Block a user