Refactor Metadata

This commit is contained in:
Dustin Brett
2021-01-16 22:44:46 -08:00
parent 531736b9f4
commit ac0a3a4a5d
3 changed files with 25 additions and 6 deletions

View File

@@ -0,0 +1,19 @@
import Head from 'next/head';
import {
description as packageDescription,
name as packageName
} from 'package.json';
import type { FC } from 'react';
import type { MetadataProps } from 'types/components/pages/Metadata';
const Metadata: FC<MetadataProps> = ({
description = packageDescription,
title = packageName
}) => (
<Head>
<meta name="description" content={description} />
<title>{title}</title>
</Head>
);
export default Metadata;

View File

@@ -1,16 +1,12 @@
import Metadata from 'components/pages/Metadata';
import StyledApp from 'components/pages/StyledApp';
import type { AppProps } from 'next/app';
import Head from 'next/head';
import { description, name } from 'package.json';
import type { ReactElement } from 'react';
export default function App({ Component, pageProps }: AppProps): ReactElement {
return (
<>
<Head>
<title>{name}</title>
<meta name="description" content={description} />
</Head>
<Metadata />
<StyledApp>
<Component {...pageProps} />
</StyledApp>

View File

@@ -0,0 +1,4 @@
export type MetadataProps = {
description?: string;
title?: string;
};