feat: use dynamic environment variable import
This commit is contained in:
@@ -18,7 +18,7 @@ import type {
|
|||||||
} from '$lib/types/data';
|
} from '$lib/types/data';
|
||||||
import type { ComponentKeys } from '$lib/types/strapi';
|
import type { ComponentKeys } from '$lib/types/strapi';
|
||||||
import type { Component } from 'svelte';
|
import type { Component } from 'svelte';
|
||||||
import { PUBLIC_STRAPI_URL } from '$env/static/public';
|
import { env as publicEnv } from '$env/dynamic/public';
|
||||||
|
|
||||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
export const cmsComponentMapping: Record<ComponentKeys, Promise<{ default: Component<any> }>> = {
|
export const cmsComponentMapping: Record<ComponentKeys, Promise<{ default: Component<any> }>> = {
|
||||||
@@ -32,7 +32,7 @@ export const mapHeaderData = (data: StrapiHomepageResponse): Header => {
|
|||||||
const links: HeaderLink[] = data.data.components.map((component) => {
|
const links: HeaderLink[] = data.data.components.map((component) => {
|
||||||
if (component.__component === 'shared.profile') {
|
if (component.__component === 'shared.profile') {
|
||||||
return {
|
return {
|
||||||
label: "Profile",
|
label: 'Profile',
|
||||||
href: `#${component.profile.anchor_id}`
|
href: `#${component.profile.anchor_id}`
|
||||||
};
|
};
|
||||||
} else if (component.__component === 'shared.project') {
|
} else if (component.__component === 'shared.project') {
|
||||||
@@ -72,7 +72,7 @@ const mapProfileData = (data: StrapiProfileComponent): Profile => {
|
|||||||
title: data.profile.title,
|
title: data.profile.title,
|
||||||
anchorId: data.profile.anchor_id,
|
anchorId: data.profile.anchor_id,
|
||||||
text: data.profile.description,
|
text: data.profile.description,
|
||||||
imageUrl: PUBLIC_STRAPI_URL + data.profile.image.formats.small.url
|
imageUrl: publicEnv.PUBLIC_STRAPI_URL + data.profile.image.formats.small.url
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { STRAPI_API_KEY } from '$env/static/private';
|
import { env as privateEnv } from '$env/dynamic/private';
|
||||||
import { PUBLIC_STRAPI_URL } from '$env/static/public';
|
import { env as publicEnv } from '$env/dynamic/public';
|
||||||
import type { LayoutServerLoad } from './$types';
|
import type { LayoutServerLoad } from './$types';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
import { mapFooterData, mapHeaderData } from '$lib/mapping/strapiMapping.svelte.js';
|
import { mapFooterData, mapHeaderData } from '$lib/mapping/strapiMapping.svelte.js';
|
||||||
@@ -24,13 +24,13 @@ export const load: LayoutServerLoad = async () => {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
Authorization: `Bearer ${STRAPI_API_KEY}`
|
Authorization: `Bearer ${privateEnv.STRAPI_API_KEY}`
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const [homepageResponse, footerResponse] = await Promise.allSettled([
|
const [homepageResponse, footerResponse] = await Promise.allSettled([
|
||||||
fetch(`${PUBLIC_STRAPI_URL}/api/homepage?${query}`, requestInit),
|
fetch(`${publicEnv.PUBLIC_STRAPI_URL}/api/homepage?${query}`, requestInit),
|
||||||
fetch(`${PUBLIC_STRAPI_URL}/api/footer`, requestInit)
|
fetch(`${publicEnv.PUBLIC_STRAPI_URL}/api/footer`, requestInit)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user