mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 15:09:47 +00:00
85 lines
2.2 KiB
TypeScript
85 lines
2.2 KiB
TypeScript
import Head from 'next/head'
|
|
import * as 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
|
|
url?: string
|
|
}
|
|
> = ({ site, title, description, pageId, image, url }) => {
|
|
const rssFeedUrl = `${config.host}/feed.xml`
|
|
|
|
title = title ?? site?.name
|
|
description = description ?? site?.description
|
|
|
|
const socialImageUrl = getSocialImageUrl(pageId) || image
|
|
|
|
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='robots' content='index,follow' />
|
|
<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} />
|
|
</>
|
|
)}
|
|
|
|
<link
|
|
rel='alternate'
|
|
type='application/rss+xml'
|
|
href={rssFeedUrl}
|
|
title={site?.name}
|
|
/>
|
|
|
|
<meta property='og:title' content={title} />
|
|
<meta name='twitter:title' content={title} />
|
|
<title>{title}</title>
|
|
</Head>
|
|
)
|
|
}
|