Skip to content

Commit

Permalink
Added in params for GA & Disqus
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeraze committed Nov 20, 2022
1 parent 138eb7c commit 2df7dee
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 5 deletions.
5 changes: 3 additions & 2 deletions components/NotionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,14 @@ export const NotionPage: React.FC<types.PageProps> = ({


const disqus =<DiscussionEmbed
shortname='yerazesdomain'
shortname={config.disqusShortname}
config={ {
url: canonicalPageUrl,
title: title
} }
/>


return (
<>
<PageHead
Expand Down Expand Up @@ -289,7 +290,7 @@ export const NotionPage: React.FC<types.PageProps> = ({
mapImageUrl={mapImageUrl}
searchNotion={config.isSearchEnabled ? searchNotion : null}
pageAside={pageAside}
pageFooter={pageId === site.rootNotionPageId ? null : disqus}
pageFooter={pageId === site.rootNotionPageId ? null : (config.disqusShortname ? disqus : null)}
footer={footer}
/>
</>
Expand Down
5 changes: 5 additions & 0 deletions lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export const navigationLinks: Array<NavigationLink | null> = getSiteConfig(
null
)

export const googleAnalyticsId : string | null = getSiteConfig('googleAnalyticsId', null)
export const disqusShortname : string | null = getSiteConfig('disqusShortname', null)

// Optional site search
export const isSearchEnabled: boolean = getSiteConfig('isSearchEnabled', true)

Expand Down Expand Up @@ -167,6 +170,8 @@ export const fathomConfig = fathomId
}
: undefined



export const posthogId = process.env.NEXT_PUBLIC_POSTHOG_ID
export const posthogConfig: posthog.Config = {
api_host: 'https://app.posthog.com'
Expand Down
3 changes: 3 additions & 0 deletions lib/site-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export interface SiteConfig {
zhihu?: string
mastodon?: string;

googleAnalyticsId?: string | null
disqusShortname?: string | null

defaultPageIcon?: string | null
defaultPageCover?: string | null
defaultPageCoverPosition?: number | null
Expand Down
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"react": "^18.2.0",
"react-body-classname": "^1.3.1",
"react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-notion-x": "^6.15.6",
"react-tweet-embed": "^2.0.0",
"react-use": "^17.3.2",
Expand Down
11 changes: 10 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { AppProps } from 'next/app'
import { useRouter } from 'next/router'

import * as Fathom from 'fathom-client'
import ReactGA from 'react-ga'
// used for rendering equations (optional)
import 'katex/dist/katex.min.css'
import posthog from 'posthog-js'
Expand All @@ -25,7 +26,8 @@ import {
fathomId,
isServer,
posthogConfig,
posthogId
posthogId,
googleAnalyticsId
} from '@/lib/config'

if (!isServer) {
Expand All @@ -44,6 +46,10 @@ export default function App({ Component, pageProps }: AppProps) {
if (posthogId) {
posthog.capture('$pageview')
}

if (googleAnalyticsId) {
ReactGA.pageview('$pageview')
}
}

if (fathomId) {
Expand All @@ -54,6 +60,9 @@ export default function App({ Component, pageProps }: AppProps) {
posthog.init(posthogId, posthogConfig)
}

if (googleAnalyticsId) {
ReactGA.initialize( googleAnalyticsId)
}
router.events.on('routeChangeComplete', onRouteChangeComplete)

return () => {
Expand Down
4 changes: 4 additions & 0 deletions site.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export default siteConfig({
// }
pageUrlOverrides: null,

googleAnalyticsId: 'UA-274734-1',

disqusShortname: 'yerazesdomain',

// whether to use the default notion navigation style or a custom one with links to
// important pages
navigationStyle: 'default'
Expand Down
9 changes: 7 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,7 @@
"resolved" "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz"
"version" "2.0.1"

"prop-types@^15.5.6", "prop-types@^15.6.2", "prop-types@^15.7.2", "prop-types@^15.8.1":
"prop-types@^15.5.6", "prop-types@^15.6.0", "prop-types@^15.6.2", "prop-types@^15.7.2", "prop-types@^15.8.1":
"integrity" "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg=="
"resolved" "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz"
"version" "15.8.1"
Expand Down Expand Up @@ -2899,6 +2899,11 @@
"resolved" "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz"
"version" "3.2.0"

"react-ga@^3.3.1":
"integrity" "sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ=="
"resolved" "https://registry.npmjs.org/react-ga/-/react-ga-3.3.1.tgz"
"version" "3.3.1"

"react-hotkeys-hook@^3.0.3":
"integrity" "sha512-vaORq07rWgmuF3owWRhgFV/3VL8/l2q9lz0WyVEddJnWTtKW+AOgU5YgYKuwN6h6h7bCcLG3MFsJIjCrM/5DvQ=="
"resolved" "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-3.4.4.tgz"
Expand Down Expand Up @@ -3017,7 +3022,7 @@
"ts-easing" "^0.2.0"
"tslib" "^2.1.0"

"react@*", "react@^0.14.0 || ^15.0.0 || ^16 || ^17", "react@^15 || ^16", "react@^15.0.0 || ^16.0.0 || ^17.0.0", "react@^15.6.1 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^16.3.0 || ^17.0.0", "react@^16.3.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0", "react@^16.8.0 || ^17.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^17.0.2 || ^18.0.0-0", "react@^18.2.0", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", "react@>=16", "react@>=16.8", "react@>=16.8.0", "react@>=16.8.1", "react@>=17":
"react@*", "react@^0.14.0 || ^15.0.0 || ^16 || ^17", "react@^15 || ^16", "react@^15.0.0 || ^16.0.0 || ^17.0.0", "react@^15.6.1 || ^16.0.0 || ^17.0.0 || ^18.0.0", "react@^15.6.2 || ^16.0 || ^17 || ^18", "react@^16.3.0 || ^17.0.0", "react@^16.3.0 || ^17.0.0 || ^18.0.0", "react@^16.8.0 || ^17.0.0", "react@^16.8.0 || ^17.0.0", "react@^16.8.0 || ^17.0.0 || ^18.0.0", "react@^17.0.2 || ^18.0.0-0", "react@^18.2.0", "react@>= 16.8.0 || 17.x.x || ^18.0.0-0", "react@>=16", "react@>=16.8", "react@>=16.8.0", "react@>=16.8.1", "react@>=17":
"integrity" "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ=="
"resolved" "https://registry.npmjs.org/react/-/react-18.2.0.tgz"
"version" "18.2.0"
Expand Down

0 comments on commit 2df7dee

Please sign in to comment.