2
0

fix(docker): 🐛 Runtime public environment

This commit is contained in:
Baptiste Arnaud
2022-06-22 07:36:11 +02:00
parent 3e47b37c2e
commit f801a29539
55 changed files with 358 additions and 167 deletions

View File

@ -1,8 +1,7 @@
import React, { useEffect, useState } from 'react'
import { Text, HStack } from '@chakra-ui/react'
import { SearchableDropdown } from '../../../shared/SearchableDropdown'
import { isEmpty } from 'utils'
import getConfig from 'next/config'
import { env, isEmpty } from 'utils'
type FontSelectorProps = {
activeFont?: string
@ -21,12 +20,11 @@ export const FontSelector = ({
}, [])
const fetchPopularFonts = async () => {
const {
publicRuntimeConfig: { NEXT_PUBLIC_GOOGLE_API_KEY },
} = getConfig()
if (isEmpty(NEXT_PUBLIC_GOOGLE_API_KEY)) return []
if (isEmpty(env('GOOGLE_API_KEY'))) return []
const response = await fetch(
`https://www.googleapis.com/webfonts/v1/webfonts?key=${NEXT_PUBLIC_GOOGLE_API_KEY}&sort=popularity`
`https://www.googleapis.com/webfonts/v1/webfonts?key=${env(
'GOOGLE_API_KEY'
)}&sort=popularity`
)
return (await response.json()).items.map(
(item: { family: string }) => item.family