refactor(config): improve projectConfig file with types

This commit is contained in:
Walid 2022-03-24 14:46:54 +01:00
parent 5a82f96c7d
commit 2d2ef2457d
No known key found for this signature in database
GPG Key ID: 4BDA1ABD227F9279
2 changed files with 18 additions and 27 deletions

8
types/projectConfig.ts Normal file
View File

@ -0,0 +1,8 @@
type PCKeys = 'shortName' | 'longName' | 'description' | 'url' | 'color'
type PCIconsKeys = 'default' | 'image' | 'apple' | '16_16' | '32_32'
type PCProps = Record<PCKeys, string>
export interface PCDefaultValues extends PCProps {
icons: Record<PCIconsKeys, string>
}

View File

@ -1,33 +1,16 @@
type PCProps = 'shortName' | 'longName' | 'description' | 'url' | 'color'
type PCDefaultValues = Record<PCProps, string>
import { PCDefaultValues } from 'types/projectConfig'
const projectDefaultConfigValues: PCDefaultValues = {
export const projectConfig: PCDefaultValues = {
shortName: 'Unknown project name',
longName: 'Unknown project name',
description: 'Unknown project description',
url: 'Unknown project url',
color: '#FF0000'
}
export const projectConfig = {
shortName:
process.env.NEXT_PUBLIC_PROJECT_SHORT_NAME != null
? process.env.NEXT_PUBLIC_PROJECT_SHORT_NAME
: projectDefaultConfigValues.shortName,
longName:
process.env.NEXT_PUBLIC_PROJECT_LONG_NAME != null
? process.env.NEXT_PUBLIC_PROJECT_LONG_NAME
: projectDefaultConfigValues.longName,
description:
process.env.NEXT_PUBLIC_PROJECT_DESCRIPTION != null
? process.env.NEXT_PUBLIC_PROJECT_DESCRIPTION
: projectDefaultConfigValues.description,
url:
process.env.NEXT_PUBLIC_PROJECT_URL != null
? process.env.NEXT_PUBLIC_PROJECT_URL
: projectDefaultConfigValues.url,
color:
process.env.NEXT_PUBLIC_PROJECT_COLOR != null
? process.env.NEXT_PUBLIC_PROJECT_COLOR
: projectDefaultConfigValues.color
color: '#FF0000',
icons: {
image: '/images/Logo.png',
default: '/icons/favicons/favicon.ico',
apple: '/icons/favicons/apple-touch-icon.png',
'16_16': '/icons/favicons/favicon-16x16.png',
'32_32': '/icons/favicons/favicon-32x32.png'
}
}