diff --git a/components/Head.tsx b/components/Head.tsx index 94f76d5..f3611b5 100644 --- a/components/Head.tsx +++ b/components/Head.tsx @@ -1,40 +1,77 @@ import NextHead from 'next/head' -const Head: React.FC = () => { - const data = { - title: process.env.NEXT_PUBLIC_PROJECT_NAME, - description: process.env.NEXT_PUBLIC_PROJECT_DESCRIPTION, - image: '/images/icons/64x64.png', - url: 'https://urlwebsite.fr/' +import { projectConfig } from '@/utils/config' + +interface HeadProps { + longName?: string + shortName?: string + description?: string + color?: string +} + +type HeadDataIconsProps = 'default' | 'image' | 'apple' | '16_16' | '32_32' +type INextHeadIcons = Record + +const Head: React.FC = (props) => { + const { + longName = projectConfig.longName, + shortName = projectConfig.shortName, + description = projectConfig.description, + color = projectConfig.color, + children + } = props + + const icons: INextHeadIcons = { + 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' } return ( - {data.title} + + {props.longName == null + ? longName + : props.shortName == null && shortName} + - - + {/* Link Tags */} + + + + - {/* Meta Tag */} + {/* Default meta tags */} - - - + + + + + + + + + + - {/* Open Graph Metadata */} - + {/* Open graph MT */} + - - - + + + - + {/* Twitter card Metadata */} - - - + + + + + {children} ) } diff --git a/utils/config.ts b/utils/config.ts index 4d3a4d9..7bc951b 100644 --- a/utils/config.ts +++ b/utils/config.ts @@ -1,4 +1,33 @@ -export const PROJECT_NAME = - process.env.NEXT_PUBLIC_PROJECT_NAME != null - ? process.env.NEXT_PUBLIC_PROJECT_NAME - : 'unknown project' +type PCProps = 'shortName' | 'longName' | 'description' | 'url' | 'color' +type PCDefaultValues = Record + +const projectDefaultConfigValues: 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 +}