Files
Compass/web/components/SEO.tsx
Martin Braquet ba9b3cfb06 Add pretty formatting (#29)
* Test

* Add pretty formatting

* Fix Tests

* Fix Tests

* Fix Tests

* Fix

* Add pretty formatting fix

* Fix

* Test

* Fix tests

* Clean typeckech

* Add prettier check

* Fix api tsconfig

* Fix api tsconfig

* Fix tsconfig

* Fix

* Fix

* Prettier
2026-02-20 17:32:27 +01:00

52 lines
1.5 KiB
TypeScript

import {isProd} from 'common/envs/is-prod'
import {removeUndefinedProps} from 'common/util/object'
import {buildOgUrl} from 'common/util/og'
import Head from 'next/head'
export function SEO<P extends Record<string, string | undefined>>(props: {
title: string
description: string
url?: string
ogProps?: {props: P; endpoint: string}
image?: string
}) {
const {title, description, url, image, ogProps} = props
const imageUrl =
image ?? (ogProps && buildOgUrl(removeUndefinedProps(ogProps.props) as any, ogProps.endpoint))
const absUrl = 'https://compassmeet.com' + url
const endTitle = isProd() ? 'Compass' : 'Compass dev'
return (
<Head>
<title>{`${title} | ${endTitle}`}</title>
<meta property="og:title" name="twitter:title" content={title} key="title" />
<meta name="description" content={description} key="description1" />
<meta
property="og:description"
name="twitter:description"
content={description}
key="description2"
/>
{url && <link rel="canonical" href={absUrl} />}
{url && <meta property="og:url" content={absUrl} key="url" />}
{url && (
<meta name="apple-itunes-app" content={'app-id=6444136749, app-argument=' + absUrl} />
)}
{imageUrl && (
<>
<meta property="og:image" content={imageUrl} key="image1" />
<meta name="twitter:card" content="summary_large_image" key="card" />
<meta name="twitter:image" content={imageUrl} key="image2" />
</>
)}
</Head>
)
}