2
0

fix(docker): 🐛 Runtime public environment

This commit is contained in:
Baptiste Arnaud
2022-06-21 10:36:41 +02:00
parent ea765640cf
commit e03fe9f7d9
54 changed files with 349 additions and 164 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