-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
11 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,19 @@ | ||
import Head from 'next/head'; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
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; | ||
interface Props { | ||
children: React.ReactNode; | ||
query?: PageProps<Pathname>['query']; | ||
apiData?: PageProps<Pathname>['apiData']; | ||
pathname?: any; | ||
query?: any; | ||
apiData?: any; | ||
} | ||
|
||
initSentry(); | ||
|
||
const PageNextJs = <Pathname extends Route['pathname']>(props: Props<Pathname>) => { | ||
const { title, description, opengraph, canonical } = metadata.generate(props, props.apiData); | ||
|
||
useGetCsrfToken(); | ||
useAdblockDetect(); | ||
|
||
const isMixpanelInited = mixpanel.useInit(); | ||
mixpanel.useLogPageView(isMixpanelInited); | ||
|
||
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> | ||
{ props.children } | ||
</> | ||
); | ||
}; | ||
const PageNextJs = (props: Props) => ( | ||
<div>{ props.children }</div> | ||
); | ||
|
||
export default React.memo(PageNextJs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters