🚧 Migrate env variables to use internal SvelteKit system

Some API fetching function rewriting needed as privates cannot be included into public code
This commit is contained in:
2022-08-16 16:58:57 +02:00
parent 5e5c08ddd1
commit 6e904850aa
12 changed files with 131 additions and 92 deletions

View File

@@ -1,6 +1,7 @@
import { error } from '@sveltejs/kit'
import type { PageServerLoad } from './$types'
import { fetchAPI } from '$utils/api'
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
export const load: PageServerLoad = async () => {
@@ -21,7 +22,7 @@ export const load: PageServerLoad = async () => {
date_updated
photos (
sort: "-date_created",
limit: ${import.meta.env.VITE_PREVIEW_COUNT}
limit: ${PUBLIC_PREVIEW_COUNT}
) {
image {
id
@@ -87,14 +88,14 @@ export const load: PageServerLoad = async () => {
`)
if (res) {
const { data } = res
const { data: { countPhotos, countLocations, countCountries, ...rest }} = res
return {
...data,
...rest,
count: {
photos: data.countPhotos[0].count.id,
locations: data.countLocations[0].count.id,
countries: data.countCountries[0].count.id,
photos: countPhotos[0].count.id,
locations: countLocations[0].count.id,
countries: countCountries[0].count.id,
},
}
}