2019-08-01 04:05:23 +02:00
|
|
|
// @flow strict
|
2018-11-09 18:08:48 +01:00
|
|
|
import React from 'react';
|
|
|
|
import Helmet from 'react-helmet';
|
2019-08-25 12:29:51 +02:00
|
|
|
import { withPrefix } from 'gatsby';
|
2019-05-10 01:15:43 +02:00
|
|
|
import type { Node as ReactNode } from 'react';
|
2019-08-25 12:29:51 +02:00
|
|
|
import { useSiteMetadata } from '../../hooks';
|
2018-11-09 18:08:48 +01:00
|
|
|
import styles from './Layout.module.scss';
|
|
|
|
|
2019-05-10 01:15:43 +02:00
|
|
|
type Props = {
|
|
|
|
children: ReactNode,
|
|
|
|
title: string,
|
2019-08-25 13:20:50 +02:00
|
|
|
description?: string,
|
|
|
|
socialImage? :string
|
2019-05-10 01:15:43 +02:00
|
|
|
};
|
|
|
|
|
2019-08-25 14:15:37 +02:00
|
|
|
const Layout = ({
|
2019-08-25 13:50:36 +02:00
|
|
|
children,
|
|
|
|
title,
|
|
|
|
description,
|
|
|
|
socialImage
|
|
|
|
}: Props) => {
|
2019-08-25 12:29:51 +02:00
|
|
|
const { author, url } = useSiteMetadata();
|
|
|
|
const metaImage = socialImage != null ? socialImage : author.photo;
|
|
|
|
const metaImageUrl = url + withPrefix(metaImage);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.layout}>
|
|
|
|
<Helmet>
|
|
|
|
<html lang="en" />
|
|
|
|
<title>{title}</title>
|
|
|
|
<meta name="description" content={description} />
|
|
|
|
<meta property="og:site_name" content={title} />
|
|
|
|
<meta name="twitter:card" content="summary" />
|
|
|
|
<meta name="twitter:title" content={title} />
|
|
|
|
<meta name="twitter:description" content={description} />
|
|
|
|
<meta name="twitter:image" content={metaImageUrl} />
|
|
|
|
</Helmet>
|
|
|
|
{children}
|
|
|
|
</div>
|
2019-08-25 13:50:36 +02:00
|
|
|
);
|
2019-08-25 12:29:51 +02:00
|
|
|
};
|
2018-11-09 18:08:48 +01:00
|
|
|
|
|
|
|
export default Layout;
|