Add files via upload
This commit is contained in:
51
src/components/SeoHead/SeoHead.tsx
Normal file
51
src/components/SeoHead/SeoHead.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import { FC } from 'react';
|
||||
|
||||
import Head from 'next/head';
|
||||
|
||||
type Tags = Array<string> ;
|
||||
|
||||
type SeoHeadProps = {
|
||||
tabTitle: string;
|
||||
title: string;
|
||||
canonical?: string;
|
||||
ogUrl?: string
|
||||
description: string;
|
||||
keywords?: string;
|
||||
imageSource?: string;
|
||||
videoTags?: Tags;
|
||||
bookTags?: Tags;
|
||||
};
|
||||
|
||||
const getTags = (tagName: 'video' | 'book', tags?: Tags) => tags && tags.length && tags.map((tag, i) => <meta
|
||||
key={`${tag}-${i}`}
|
||||
content={tag}
|
||||
property={`${tagName}:tag`}
|
||||
/>);
|
||||
|
||||
const SeoHead: FC<SeoHeadProps> = ({
|
||||
tabTitle,
|
||||
title,
|
||||
canonical,
|
||||
ogUrl,
|
||||
description,
|
||||
keywords,
|
||||
imageSource,
|
||||
videoTags,
|
||||
bookTags,
|
||||
}) => (<Head>
|
||||
<title>{tabTitle}</title>
|
||||
<meta content={title} property="og:title" />
|
||||
<meta content={title} property="twitter:title" />
|
||||
<meta content={description} name="og:description" />
|
||||
<meta content={description} name="twitter:description" />
|
||||
<meta content={description} name="description" />
|
||||
{canonical && <link rel="canonical" href={canonical} />}
|
||||
{ogUrl && <meta content={ogUrl} property="og:url" />}
|
||||
{getTags('video', videoTags)}
|
||||
{getTags('book', bookTags)}
|
||||
{imageSource && <meta content={imageSource} property="og:image"/>}
|
||||
{imageSource && <meta content={imageSource} property="twitter:image"/>}
|
||||
{keywords && <meta content={keywords} name="Keywords" />}
|
||||
</Head>);
|
||||
|
||||
export default SeoHead;
|
||||
1
src/components/SeoHead/index.ts
Normal file
1
src/components/SeoHead/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './SeoHead';
|
||||
Reference in New Issue
Block a user