import React, { FC } from 'react'; import HTMLReactParser, { domToReact } from 'html-react-parser'; import Head from 'next/head'; import { FontFaceGenerator, Meta, Project, FontVault } from '@cntrl-site/sdk'; interface Props { project: Project; meta: Meta; slug?: string; siteUrl?: string; fontsVault: FontVault[]; } export const CNTRLHead: FC = ({ meta, project, slug, siteUrl, fontsVault }) => { const canonicalUrl = buildCanonicalUrl(siteUrl ?? project.primaryDomain, slug); const googleFonts: ReturnType = HTMLReactParser(project.fonts.google); const adobeFonts: ReturnType = HTMLReactParser(project.fonts.adobe); const parsedFonts = { ...(typeof googleFonts === 'object' ? googleFonts : {}), ...(typeof adobeFonts === 'object' ? adobeFonts : {}) }; const customFonts = project.fonts.custom; const htmlHead = HTMLReactParser(project.html.head); const ffGenerator = new FontFaceGenerator([...fontsVault, ...customFonts]); const links = Object.values(parsedFonts as ReturnType).map((value) => { if (!value) return null; const rel = value?.rel || value.props?.rel; const href = value?.href || value.props?.href; if (!rel || !href) return null; return ( ); }); return ( {meta.title} {canonicalUrl && } {canonicalUrl && }