mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* simple fetch data for token instance page * generate enhanced metadata * group query params in page props * make base gSSP function generic * add metric for search engine bots * measure api request duration * get API data for token, address and dapp pages * improve typings for apiData prop * add ENV variable * tweak logs for /media-type requests * [skip ci] add prefix to default metrics
57 lines
1.9 KiB
TypeScript
57 lines
1.9 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 useAdblockDetect from 'lib/hooks/useAdblockDetect';
|
|
import useGetCsrfToken from 'lib/hooks/useGetCsrfToken';
|
|
import * as metadata from 'lib/metadata';
|
|
import * as mixpanel from 'lib/mixpanel';
|
|
import { init as initSentry } from 'lib/sentry/config';
|
|
|
|
interface Props<Pathname extends Route['pathname']> {
|
|
pathname: Pathname;
|
|
children: React.ReactNode;
|
|
query?: PageProps<Pathname>['query'];
|
|
apiData?: PageProps<Pathname>['apiData'];
|
|
}
|
|
|
|
initSentry();
|
|
|
|
const PageNextJs = <Pathname extends Route['pathname']>(props: Props<Pathname>) => {
|
|
const { title, description, opengraph } = metadata.generate(props, props.apiData);
|
|
|
|
useGetCsrfToken();
|
|
useAdblockDetect();
|
|
|
|
const isMixpanelInited = mixpanel.useInit();
|
|
mixpanel.useLogPageView(isMixpanelInited);
|
|
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>{ title }</title>
|
|
<meta name="description" content={ description }/>
|
|
|
|
{ /* 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>
|
|
{ props.children }
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default React.memo(PageNextJs);
|