Move API fields to file

This commit is contained in:
2022-09-06 14:51:47 +02:00
parent 5ff82f4ee4
commit 3d7b859d12
3 changed files with 19 additions and 14 deletions

View File

@@ -1,20 +1,8 @@
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
import { PUBLIC_LIST_AMOUNT } from '$env/static/public'
import { fetchAPI } from '$utils/api'
import { fetchAPI, photoFields } from '$utils/api'
export const photoFields = `
title
slug
city
image {
id
title
width, height
}
date_taken
date_created
`
export const load: PageServerLoad = async ({ params }) => {
try {

View File

@@ -12,7 +12,7 @@
import { quartOut } from '$animations/easings'
import { getAssetUrlKey } from '$utils/api'
import { DELAY } from '$utils/contants'
import { photoFields } from './+page.server'
import { photoFields } from '$utils/api'
import { PUBLIC_LIST_INCREMENT } from '$env/static/public'
// Components
import Metas from '$components/Metas.svelte'

View File

@@ -43,6 +43,23 @@ export const getAssetUrlKey = (
}
/**
* GraphQL fields
*/
export const photoFields = `
title
slug
city
image {
id
title
width, height
}
date_taken
date_created
`
/**
* Get a Directus asset URL from parameters
*/