🚧 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:
@@ -1,16 +1,14 @@
|
||||
import { error } from '@sveltejs/kit'
|
||||
import type { PageServerLoad } from './$types'
|
||||
import { fetchAPI } from '$utils/api'
|
||||
import { PUBLIC_FILTERS_DEFAULT_COUNTRY, PUBLIC_FILTERS_DEFAULT_SORT, PUBLIC_GRID_AMOUNT } from '$env/static/public'
|
||||
|
||||
// Default filters values
|
||||
const defaultCountry = String(import.meta.env.VITE_FILTERS_DEFAULT_COUNTRY)
|
||||
const defaultSort = String(import.meta.env.VITE_FILTERS_DEFAULT_SORT)
|
||||
|
||||
export const load: PageServerLoad = async ({ url }) => {
|
||||
try {
|
||||
// Query parameters
|
||||
const queryCountry = url.searchParams.get('country') || defaultCountry
|
||||
const querySort = url.searchParams.get('sort') || defaultSort
|
||||
const queryCountry = url.searchParams.get('country') || PUBLIC_FILTERS_DEFAULT_COUNTRY
|
||||
const querySort = url.searchParams.get('sort') || PUBLIC_FILTERS_DEFAULT_SORT
|
||||
|
||||
// Query
|
||||
const res = await fetchAPI(`
|
||||
@@ -21,7 +19,7 @@ export const load: PageServerLoad = async ({ url }) => {
|
||||
status: { _eq: "published" },
|
||||
},
|
||||
sort: "${querySort === 'latest' ? '-' : ''}date_created",
|
||||
limit: ${import.meta.env.VITE_GRID_AMOUNT},
|
||||
limit: ${PUBLIC_GRID_AMOUNT},
|
||||
page: 1,
|
||||
) {
|
||||
id
|
||||
|
||||
Reference in New Issue
Block a user