mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
97 lines
2.3 KiB
TypeScript
97 lines
2.3 KiB
TypeScript
import Head from 'next/head'
|
|
import React from 'react'
|
|
|
|
import * as types from 'lib/types'
|
|
import * as config from 'lib/config'
|
|
import { getSocialImageUrl } from 'lib/get-social-image-url'
|
|
|
|
export const PageHead: React.FC<
|
|
types.PageProps & {
|
|
title?: string
|
|
description?: string
|
|
image?: string
|
|
imageObjectPosition?: string
|
|
author?: string
|
|
authorImage?: string
|
|
detail?: string
|
|
url?: string
|
|
}
|
|
> = ({
|
|
site,
|
|
title,
|
|
description,
|
|
image,
|
|
imageObjectPosition,
|
|
author,
|
|
authorImage,
|
|
detail,
|
|
url
|
|
}) => {
|
|
title = title ?? site?.name
|
|
description = description ?? site?.description
|
|
|
|
const socialImageUrl = getSocialImageUrl({
|
|
title,
|
|
image,
|
|
imageObjectPosition,
|
|
author,
|
|
authorImage,
|
|
detail
|
|
})
|
|
|
|
return (
|
|
<Head>
|
|
<meta charSet='utf-8' />
|
|
<meta httpEquiv='Content-Type' content='text/html; charset=utf-8' />
|
|
<meta
|
|
name='viewport'
|
|
content='width=device-width, initial-scale=1, shrink-to-fit=no'
|
|
/>
|
|
|
|
<meta name='theme-color' content='#EB625A' />
|
|
<meta property='og:type' content='website' />
|
|
|
|
{site && (
|
|
<>
|
|
<meta property='og:site_name' content={site.name} />
|
|
<meta property='twitter:domain' content={site.domain} />
|
|
</>
|
|
)}
|
|
|
|
{config.twitter && (
|
|
<meta name='twitter:creator' content={`@${config.twitter}`} />
|
|
)}
|
|
|
|
{description && (
|
|
<>
|
|
<meta name='description' content={description} />
|
|
<meta property='og:description' content={description} />
|
|
<meta name='twitter:description' content={description} />
|
|
</>
|
|
)}
|
|
|
|
{socialImageUrl ? (
|
|
<>
|
|
<meta name='twitter:card' content='summary_large_image' />
|
|
<meta name='twitter:image' content={socialImageUrl} />
|
|
<meta property='og:image' content={socialImageUrl} />
|
|
</>
|
|
) : (
|
|
<meta name='twitter:card' content='summary' />
|
|
)}
|
|
|
|
{url && (
|
|
<>
|
|
<link rel='canonical' href={url} />
|
|
<meta property='og:url' content={url} />
|
|
<meta property='twitter:url' content={url} />
|
|
</>
|
|
)}
|
|
|
|
<meta property='og:title' content={title} />
|
|
<meta name='twitter:title' content={title} />
|
|
<title>{title}</title>
|
|
</Head>
|
|
)
|
|
}
|