mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* Page meta tags are not generated on the server Fixes #2730 * suppress warnings about critical dependencies in Next.js logs
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import Head from 'next/head';
|
|
import React from 'react';
|
|
|
|
import type { Route } from 'nextjs-routes';
|
|
import type { Props as PageProps } from 'nextjs/getServerSideProps';
|
|
|
|
import config from 'configs/app';
|
|
import * as metadata from 'lib/metadata';
|
|
|
|
interface Props<Pathname extends Route['pathname']> {
|
|
pathname: Pathname;
|
|
query?: PageProps<Pathname>['query'];
|
|
apiData?: PageProps<Pathname>['apiData'];
|
|
}
|
|
|
|
const PageMetadata = <Pathname extends Route['pathname']>(props: Props<Pathname>) => {
|
|
const { title, description, opengraph, canonical } = metadata.generate(props, props.apiData);
|
|
|
|
return (
|
|
<Head>
|
|
<title>{ title }</title>
|
|
<meta name="description" content={ description }/>
|
|
{ canonical && <link rel="canonical" href={ canonical }/> }
|
|
|
|
{ /* OG TAGS */ }
|
|
<meta property="og:title" content={ opengraph.title }/>
|
|
{ opengraph.description && <meta property="og:description" content={ opengraph.description }/> }
|
|
<meta property="og:image" content={ opengraph.imageUrl }/>
|
|
<meta property="og:type" content="website"/>
|
|
|
|
{ /* Twitter Meta Tags */ }
|
|
<meta name="twitter:card" content="summary_large_image"/>
|
|
<meta property="twitter:domain" content={ config.app.host }/>
|
|
<meta name="twitter:title" content={ opengraph.title }/>
|
|
{ opengraph.description && <meta name="twitter:description" content={ opengraph.description }/> }
|
|
<meta property="twitter:image" content={ opengraph.imageUrl }/>
|
|
</Head>
|
|
);
|
|
};
|
|
|
|
export default PageMetadata;
|