Files
pedwfrontend/components/seo/Page.js
T

120 lines
3.6 KiB
JavaScript

import Head from "next/head";
import { string } from "prop-types";
// ALl options are conditional apart from title
const PageMeta = ({
title,
imageWidth,
imageHeight,
ogImage,
ogUrl,
ogTitle,
ogType,
ogDescription,
canonicalURL,
description,
keywords,
createdAt,
updatedAt,
robots,
twitterDescription,
twitterTitle,
twitterImage,
}) => {
const facebookPage = "https://www.facebook.com/IFPMA";
return (
<>
<Head>
{title && <title>{title}</title>}
<meta property="article:publisher" content={facebookPage} />
{createdAt && (
<meta
property="article:published_time"
content={createdAt}
/>
)}
{updatedAt && (
<meta
property="article:modified_time"
content={updatedAt}
/>
)}
{description && (
<meta
property="description"
name="description"
content={description}
/>
)}
{keywords && (
<meta
property="keywords"
name="keywords"
content={keywords}
/>
)}
<meta
property="robots"
name="robots"
content={robots || "index,follow"}
/>
{canonicalURL && <link rel="canonical" href={canonicalURL} />}
{ogUrl && <meta property="og:url" content={ogUrl} />}
{ogTitle && <meta property="og:title" content={ogTitle} />}
{ogType && <meta property="og:type" content={ogType} />}
{ogDescription && (
<meta property="og:description" content={ogDescription} />
)}
{ogImage && <meta property="og:image" content={ogImage} />}
{imageWidth && (
<meta property="og:image:width" content={imageWidth} />
)}
{imageHeight && (
<meta property="og:image:height" content={imageHeight} />
)}
<meta property="twitter:card" content="summary_large_image" />
<meta
key="twitter:site"
property="twitter:site"
content="@IFPMA"
/>
{twitterDescription && (
<meta
property="twitter:description"
content={twitterDescription}
/>
)}
{twitterTitle && (
<meta property="twitter:title" content={twitterTitle} />
)}
{twitterImage && (
<meta property="twitter:image" content={twitterImage} />
)}
</Head>
</>
);
};
PageMeta.propTypes = {
title: string,
createdAt: string,
updatedAt: string,
ogImage: string,
ogUrl: string,
ogTitle: string,
ogType: string,
ogDescription: string,
canonicalURL: string,
description: string,
keywords: string,
createdAt: string,
updatedAt: string,
robots: string,
twitterDescription: string,
twitterTitle: string,
twitterImage: string,
};
export default PageMeta;