Skip to content

Commit a90a677

Browse files
authored
Add Mixpanel + migrate to pnpm + update dependencies (incl. React 18 and Next 13) (graphprotocol#300)
1 parent ef15c3f commit a90a677

19 files changed

+808
-967
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ALGOLIA_API_KEY=9a358df50b02a5b66efeecbc0a2cab3d
22
ALGOLIA_APP_ID=WQ5FYJCL00
3-
NPM_TOKEN=
3+
SITE_URL=https://thegraph.com/docs

.env.example

-4
This file was deleted.

.github/workflows/ci-cd-production.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
access_token: ${{ github.token }}
2121

2222
- name: Checkout the repo
23-
uses: actions/checkout@v2
23+
uses: actions/checkout@v3
2424

2525
- name: Login to GitHub Container Registry
2626
uses: docker/login-action@v1
@@ -45,7 +45,7 @@ jobs:
4545
needs: build
4646
steps:
4747
- name: Checkout the repo
48-
uses: actions/checkout@v2
48+
uses: actions/checkout@v3
4949

5050
- name: Authenticate to GCP
5151
uses: google-github-actions/auth@v1

.github/workflows/ci-cd-pull-request.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
access_token: ${{ github.token }}
1717

1818
- name: Checkout the repo
19-
uses: actions/checkout@v2
19+
uses: actions/checkout@v3
2020

2121
- name: Build Docker image
2222
uses: docker/build-push-action@v2

.github/workflows/ci-cd-staging.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
access_token: ${{ github.token }}
2222

2323
- name: Checkout the repo
24-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2525

2626
- name: Login to GitHub Container Registry
2727
uses: docker/login-action@v1
@@ -46,7 +46,7 @@ jobs:
4646
needs: build
4747
steps:
4848
- name: Checkout the repo
49-
uses: actions/checkout@v2
49+
uses: actions/checkout@v3
5050

5151
- name: Authenticate to GCP
5252
uses: google-github-actions/auth@v1

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
enable-pre-post-scripts=true
12
engine-strict=true

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
18.14

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.yalc
22
.next
33
/out/
4+
pnpm-lock.yaml

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:16.13.1-alpine3.14 as builder
1+
FROM node:18-alpine as builder
22

33
RUN apk add --no-cache git
44
RUN npm install -g pnpm

components/Code.tsx

+1-97
Original file line numberDiff line numberDiff line change
@@ -6,103 +6,7 @@ import { BorderRadius, FontFamily, Spacing } from '@edgeandnode/components'
66
export type CodeBlockProps = HTMLAttributes<HTMLPreElement>
77
export type CodeInlineProps = HTMLAttributes<HTMLElement>
88

9-
// import theme from 'prism-react-renderer/themes/duotoneDark'
10-
// TODO: Replace the following theme definition with the above import when this PR is merged and available in a release: https://github.com/FormidableLabs/prism-react-renderer/pull/134
11-
const theme: PrismTheme = {
12-
plain: {
13-
backgroundColor: '#2a2734',
14-
color: '#9a86fd',
15-
},
16-
styles: [
17-
{
18-
types: ['comment', 'prolog', 'doctype', 'cdata', 'punctuation'],
19-
style: {
20-
color: '#6c6783',
21-
},
22-
},
23-
{
24-
types: ['namespace'],
25-
style: {
26-
opacity: 0.7,
27-
},
28-
},
29-
{
30-
types: ['tag', 'operator', 'number'],
31-
style: {
32-
color: '#e09142',
33-
},
34-
},
35-
{
36-
types: ['property', 'function'],
37-
style: {
38-
color: '#9a86fd',
39-
},
40-
},
41-
{
42-
types: ['tag-id', 'selector', 'atrule-id'],
43-
style: {
44-
color: '#eeebff',
45-
},
46-
},
47-
{
48-
types: ['attr-name'],
49-
style: {
50-
color: '#c4b9fe',
51-
},
52-
},
53-
{
54-
types: [
55-
'boolean',
56-
'string',
57-
'entity',
58-
'url',
59-
'attr-value',
60-
'keyword',
61-
'control',
62-
'directive',
63-
'unit',
64-
'statement',
65-
'regex',
66-
'atrule',
67-
'placeholder',
68-
'variable',
69-
],
70-
style: {
71-
color: '#ffcc99',
72-
},
73-
},
74-
{
75-
types: ['deleted'],
76-
style: {
77-
textDecorationLine: 'line-through',
78-
},
79-
},
80-
{
81-
types: ['inserted'],
82-
style: {
83-
textDecorationLine: 'underline',
84-
},
85-
},
86-
{
87-
types: ['italic'],
88-
style: {
89-
fontStyle: 'italic',
90-
},
91-
},
92-
{
93-
types: ['important', 'bold'],
94-
style: {
95-
fontWeight: 'bold',
96-
},
97-
},
98-
{
99-
types: ['important'],
100-
style: {
101-
color: '#c4b9fe',
102-
},
103-
},
104-
],
105-
}
9+
import theme from 'prism-react-renderer/themes/duotoneDark'
10610

10711
export const CodeBlock = ({ children, ...props }: CodeBlockProps) => {
10812
const data = (

components/DocSearch.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Global } from '@emotion/react'
33
import { useCallback, useRef, useState } from 'react'
44
import { createPortal } from 'react-dom'
55
import { Theme } from 'theme-ui'
6-
import { dispatch } from 'use-bus'
76

87
import {
98
BorderRadius,
@@ -18,9 +17,6 @@ import {
1817
Text,
1918
} from '@edgeandnode/components'
2019

21-
import { useI18n } from '../i18n'
22-
import { EventType } from '../types'
23-
2420
const BREAKPOINT = '751px'
2521

2622
export function DocSearch(props: DocSearchProps) {
@@ -30,12 +26,10 @@ export function DocSearch(props: DocSearchProps) {
3026

3127
const onOpen = useCallback(() => {
3228
setIsOpen(true)
33-
dispatch(EventType.SEARCH_OPEN)
3429
}, [setIsOpen])
3530

3631
const onClose = useCallback(() => {
3732
setIsOpen(false)
38-
dispatch(EventType.SEARCH_CLOSE)
3933
}, [setIsOpen])
4034

4135
const onInput = useCallback(

components/Link.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ export const Link = ({
4646
// If the link is external, default the target to `_blank`
4747
const finalTarget = target ?? (!isInternal ? '_blank' : undefined)
4848

49-
const nextLinkProps = {
50-
href: finalHref,
51-
replace,
52-
scroll,
53-
shallow,
54-
prefetch,
55-
}
5649
return (
57-
<NextLink {...nextLinkProps} passHref>
58-
<a target={finalTarget} rel={finalTarget === '_blank' ? 'noopener' : undefined} {...props}>
59-
{children}
60-
</a>
50+
<NextLink
51+
href={finalHref}
52+
target={finalTarget}
53+
rel={finalTarget === '_blank' ? 'noopener' : undefined}
54+
replace={replace}
55+
scroll={scroll}
56+
shallow={shallow}
57+
prefetch={prefetch}
58+
{...props}
59+
>
60+
{children}
6161
</NextLink>
6262
)
6363
}

next.config.mjs

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const env = {
99
BASE_PATH: process.env.NODE_ENV === 'production' ? '/docs' : '',
1010
ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY,
1111
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
12+
MIXPANEL_TOKEN:
13+
process.env.ENVIRONMENT === 'production' ? 'cfeac8baf33c9b4d255f28d57f3c9148' : 'e57a9892339b2acfd02943c86b746d32',
1214
}
1315

1416
const withMDX = mdx({
@@ -21,6 +23,11 @@ const withMDX = mdx({
2123
})
2224

2325
export default withMDX({
26+
experimental: {
27+
// Fix scroll restoration (see https://github.com/vercel/next.js/issues/37893#issuecomment-1221335543)
28+
scrollRestoration: true,
29+
},
30+
2431
env,
2532
pageExtensions: ['tsx', 'mdx'],
2633
reactStrictMode: true,

package.json

+20-18
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,45 @@
2323
},
2424
"dependencies": {
2525
"@docsearch/react": "^3.3.3",
26-
"@edgeandnode/components": "^25.2.0",
27-
"@emotion/react": "^11.10.5",
26+
"@edgeandnode/components": "^27.0.0",
27+
"@emotion/react": "^11.10.6",
2828
"@mdx-js/loader": "^2.3.0",
2929
"@mdx-js/react": "^2.3.0",
30-
"@next/mdx": "^12.3.4",
30+
"@next/mdx": "^13.2.3",
3131
"@radix-ui/react-collapsible": "1.0.1",
32-
"@radix-ui/react-popover": "^1.0.3",
32+
"@radix-ui/react-popover": "^1.0.4",
3333
"@radix-ui/react-visually-hidden": "^1.0.1",
3434
"@reach/auto-id": "^0.18.0",
3535
"lodash": "^4.17.21",
36-
"next": "^12.3.4",
36+
"mixpanel-browser": "^2.45.0",
37+
"next": "^13.2.3",
3738
"next-seo": "^5.15.0",
38-
"next-sitemap": "^3.1.52",
39+
"next-sitemap": "^4.0.1",
3940
"prism-react-renderer": "^1.3.5",
40-
"react": "^17.0.2",
41-
"react-dom": "^17.0.2",
42-
"react-intersection-observer": "^9.4.2",
41+
"react": "^18.2.0",
42+
"react-dom": "^18.2.0",
43+
"react-intersection-observer": "^9.4.3",
4344
"react-use": "^17.4.0",
4445
"remark-gfm": "^3.0.1",
45-
"theme-ui": "^0.15.5",
46-
"use-bus": "^2.5.2"
46+
"theme-ui": "^0.15.5"
4747
},
4848
"devDependencies": {
49-
"@edgeandnode/eslint-config": "^1.3.0",
49+
"@babel/core": "^7.21.0",
50+
"@edgeandnode/eslint-config": "^1.3.1",
5051
"@sindresorhus/slugify": "^2.2.0",
5152
"@svgr/webpack": "^6.5.1",
5253
"@types/color": "^3.0.3",
5354
"@types/lodash": "^4.14.191",
54-
"@types/node": "^16.18.12",
55-
"@types/react": "^17.0.53",
56-
"@types/react-dom": "^17.0.18",
55+
"@types/mixpanel-browser": "^2.38.1",
56+
"@types/node": "^18.14.5",
57+
"@types/react": "^18.0.28",
58+
"@types/react-dom": "^18.0.11",
5759
"acorn": "^8.8.2",
5860
"acorn-jsx": "^5.3.2",
59-
"eslint": "^8.34.0",
60-
"fast-xml-parser": "^4.1.2",
61+
"eslint": "^8.35.0",
62+
"fast-xml-parser": "^4.1.3",
6163
"husky": "^8.0.3",
62-
"lint-staged": "^13.1.1",
64+
"lint-staged": "^13.1.2",
6365
"path": "^0.12.7",
6466
"prettier": "^2.8.4",
6567
"remark-frontmatter": "^4.0.1",

0 commit comments

Comments
 (0)