Skip to content

Commit a2683c1

Browse files
authored
Update dependencies, package.json scripts, ESLint config, and Algolia Crawler config (#187)
* Update Algolia Crawler config * Update dependencies * Add `@edgeandnode/eslint-config` + update `package.json` scripts and Husky hooks * Tweak * Add `frozen-lockfile` and `ignore-scripts` flags to `yarn install` in Dockerfile
1 parent 0016c58 commit a2683c1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2906
-2146
lines changed

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
extends: ['@edgeandnode/eslint-config', '@edgeandnode/eslint-config/next'],
3+
overrides: [
4+
{
5+
files: ['*.ts', '*.tsx'],
6+
parserOptions: {
7+
project: require.resolve('./tsconfig.json'),
8+
},
9+
},
10+
],
11+
}

.eslintrc.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn pre-commit

.husky/pre-push

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn pre-push

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ COPY ./package.json /app/package.json
99
COPY ./yarn.lock /app/yarn.lock
1010

1111
# install the packages
12-
RUN yarn install
12+
RUN yarn install --frozen-lockfile --ignore-scripts
1313

1414
# copy the rest
1515
COPY . .

algolia-crawler.config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
new Crawler({
22
appId: 'WQ5FYJCL00',
33
apiKey: '[SECRET]',
4-
schedule: 'every 1 week',
4+
schedule: 'every 7 days',
5+
indexPrefix: '',
56
rateLimit: 8,
67
startUrls: [
78
'https://thegraph.com/docs/en/',
@@ -12,10 +13,10 @@ new Crawler({
1213
'https://thegraph.com/docs/vi/',
1314
'https://thegraph.com/docs/zh/',
1415
],
15-
ignoreQueryParams: ['utm_medium', 'utm_source', 'utm_campaign', 'utm_term'],
16+
ignoreQueryParams: ['source', 'utm_*'],
1617
actions: [
1718
{
18-
indexName: 'thegraph',
19+
indexName: 'thegraph-docs',
1920
pathsToMatch: ['https://thegraph.com/docs/**'],
2021
recordExtractor: ({ helpers }) => {
2122
return helpers.docsearch({
@@ -37,7 +38,7 @@ new Crawler({
3738
},
3839
],
3940
initialIndexSettings: {
40-
thegraph: {
41+
'thegraph-docs': {
4142
attributesForFaceting: ['type', 'language'],
4243
attributesToRetrieve: ['hierarchy', 'content', 'anchor', 'url', 'url_without_anchor'],
4344
attributesToHighlight: ['hierarchy', 'hierarchy_camel', 'content'],

components/Blockquote.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HTMLAttributes } from 'react'
2-
import { Text, TextProps, Spacing, buildBorder } from '@edgeandnode/components'
2+
3+
import { buildBorder, Spacing, Text, TextProps } from '@edgeandnode/components'
34

45
export type BlockquoteProps = Omit<TextProps & HTMLAttributes<HTMLQuoteElement>, 'color'>
56

@@ -8,8 +9,8 @@ export const Blockquote = ({ children, ...props }: BlockquoteProps) => {
89
<Text
910
as="blockquote"
1011
sx={{
11-
my: Spacing.XL,
12-
p: Spacing.L_XL,
12+
my: Spacing['32px'],
13+
p: Spacing['24px'],
1314
borderInlineStart: buildBorder('Purple', '4px'),
1415
bg: 'Purple8',
1516
}}

components/Code.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { HTMLAttributes } from 'react'
21
import Highlight, { defaultProps, Language, PrismTheme } from 'prism-react-renderer'
3-
import { Spacing, BorderRadius } from '@edgeandnode/components'
2+
import { HTMLAttributes } from 'react'
3+
4+
import { BorderRadius, FontFamily, Spacing } from '@edgeandnode/components'
45

56
export type CodeBlockProps = HTMLAttributes<HTMLPreElement>
67
export type CodeInlineProps = HTMLAttributes<HTMLElement>
@@ -120,17 +121,18 @@ export const CodeBlock = ({ children, ...props }: CodeBlockProps) => {
120121
}
121122

122123
return (
123-
<div sx={{ my: Spacing.L_XL }}>
124+
<div sx={{ my: Spacing['24px'] }}>
124125
<Highlight {...defaultProps} code={code} language={language as Language} theme={theme}>
125126
{({ className, tokens, getLineProps, getTokenProps }) => (
126127
<pre
127128
className={className}
128129
sx={{
129130
overflowX: 'auto',
130-
p: Spacing.L,
131+
p: Spacing['16px'],
131132
borderRadius: BorderRadius.M,
132133
border: 'White4',
133134
bg: 'White4',
135+
fontFamily: FontFamily.MONOSPACE,
134136
fontSize: '16px',
135137
lineHeight: '24px',
136138
}}
@@ -156,11 +158,12 @@ export const CodeInline = ({ children, ...props }: CodeInlineProps) => {
156158
return (
157159
<code
158160
sx={{
159-
px: '6px',
160-
py: Spacing.S,
161+
px: Spacing['4px'],
162+
py: Spacing['2px'],
161163
borderRadius: BorderRadius.S,
162164
border: 'White4',
163165
bg: 'White4',
166+
fontFamily: FontFamily.MONOSPACE,
164167
fontSize: '0.75em',
165168
}}
166169
{...props}

components/DocSearch.tsx

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
import { useRef, useState, useCallback } from 'react'
2-
import { createPortal } from 'react-dom'
3-
import { Global } from '@emotion/react'
41
import { DocSearchModal, DocSearchProps, useDocSearchKeyboardEvents } from '@docsearch/react'
2+
import { Global } from '@emotion/react'
3+
import { useCallback, useRef, useState } from 'react'
4+
import { createPortal } from 'react-dom'
5+
import { dispatch } from 'use-bus'
6+
57
import {
6-
Text,
7-
Flex,
8-
Icon,
9-
Spacing,
108
BorderRadius,
11-
Opacity,
12-
FontWeight,
13-
FontSize,
14-
buildTransition,
159
buildBorder,
10+
buildTransition,
11+
Flex,
12+
FontSize,
13+
FontWeight,
1614
GlobalTheme,
15+
Icon,
16+
Opacity,
17+
Spacing,
18+
Text,
1719
} from '@edgeandnode/components'
18-
import { dispatch } from 'use-bus'
1920

2021
import { useI18n } from '../i18n'
2122
import { EventType } from '../types'
@@ -26,7 +27,6 @@ export function DocSearch(props: DocSearchProps) {
2627
const searchButtonRef = useRef<HTMLButtonElement>(null)
2728
const [isOpen, setIsOpen] = useState(false)
2829
const [initialQuery, setInitialQuery] = useState<string | undefined>(props?.initialQuery || undefined)
29-
const { t } = useI18n()
3030

3131
const onOpen = useCallback(() => {
3232
setIsOpen(true)
@@ -55,15 +55,15 @@ export function DocSearch(props: DocSearchProps) {
5555
})
5656

5757
return (
58-
<div sx={{ px: [Spacing.L, null, null, 0] }}>
58+
<div sx={{ px: [Spacing['16px'], null, null, 0] }}>
5959
{/* TODO: Replace by `Chip` component when it's ready in the new GDS */}
6060
<button type="button" ref={searchButtonRef} onClick={onOpen} sx={{ width: '100%' }}>
6161
<Flex.Row
6262
align="center"
63-
gap={Spacing.M}
63+
gap={Spacing['8px']}
6464
sx={{
6565
height: '32px',
66-
px: Spacing.M,
66+
px: Spacing['8px'],
6767
borderRadius: BorderRadius.FULL,
6868
border: 'White4',
6969
bg: 'White4',
@@ -80,12 +80,12 @@ export function DocSearch(props: DocSearchProps) {
8080
as="kbd"
8181
size="14px"
8282
color="White48"
83-
sx={{ marginInlineStart: 'auto', px: Spacing.M, fontFamily: 'inherit' }}
83+
sx={{ marginInlineStart: 'auto', px: Spacing['8px'], fontFamily: 'inherit' }}
8484
>
8585
<abbr title="Command" sx={{ textDecoration: 'none' }}>
8686
8787
</abbr>
88-
<span sx={{ marginInlineStart: Spacing.S }}>K</span>
88+
<span sx={{ marginInlineStart: Spacing['4px'] }}>K</span>
8989
</Text.P14>
9090
</Flex.Row>
9191
</button>
@@ -128,12 +128,12 @@ export function DocSearch(props: DocSearchProps) {
128128
},
129129
},
130130
'.DocSearch-SearchBar': {
131-
padding: `0 ${Spacing.L_XL}`,
131+
padding: `0 ${Spacing['24px']}`,
132132
'&::after': {
133133
content: `''`,
134134
zIndex: 100,
135135
position: 'absolute',
136-
insetInline: Spacing.L_XL,
136+
insetInline: Spacing['24px'],
137137
bottom: '-1px',
138138
borderBottom: buildBorder('White16')(theme),
139139
backgroundColor: 'var(--docsearch-modal-background)',
@@ -150,7 +150,7 @@ export function DocSearch(props: DocSearchProps) {
150150
},
151151
},
152152
'.DocSearch-Input': {
153-
padding: `${Spacing.XL} ${Spacing.L}`,
153+
padding: `${Spacing['32px']} ${Spacing['16px']}`,
154154
outline: 'none',
155155
fontSize: FontSize['18px'],
156156
},
@@ -163,8 +163,8 @@ export function DocSearch(props: DocSearchProps) {
163163
},
164164
},
165165
'.DocSearch-Cancel': {
166-
marginInlineStart: Spacing.L,
167-
marginInlineEnd: Spacing.S,
166+
marginInlineStart: Spacing['16px'],
167+
marginInlineEnd: Spacing['4px'],
168168
color: 'inherit',
169169
},
170170
'.DocSearch-Dropdown': {
@@ -175,16 +175,16 @@ export function DocSearch(props: DocSearchProps) {
175175
scrollPaddingTop: '32px',
176176
},
177177
'.DocSearch-Dropdown-Container': {
178-
padding: `${Spacing.L_XL} ${Spacing.L}`,
179-
paddingBottom: Spacing.XXL,
178+
padding: `${Spacing['24px']} ${Spacing['16px']}`,
179+
paddingBottom: Spacing['64px'],
180180
[`@media (min-width: ${BREAKPOINT})`]: {
181-
padding: `${Spacing.L_XL} ${Spacing.XL}`,
181+
padding: `${Spacing['24px']} ${Spacing['32px']}`,
182182
},
183183
},
184184
'.DocSearch-Hits': {
185185
width: 'auto',
186186
'& + .DocSearch-Hits': {
187-
marginTop: Spacing.L,
187+
marginTop: Spacing['16px'],
188188
},
189189
mark: {
190190
color: 'inherit',
@@ -193,9 +193,9 @@ export function DocSearch(props: DocSearchProps) {
193193
},
194194
'.DocSearch-Hit-source': {
195195
margin: 0,
196-
marginBottom: Spacing.XS,
197-
padding: `0 ${Spacing.L}`,
198-
fontWeight: FontWeight.Medium,
196+
marginBottom: Spacing['2px'],
197+
padding: `0 ${Spacing['16px']}`,
198+
fontWeight: FontWeight.MEDIUM,
199199
fontSize: FontSize['12px'],
200200
textTransform: 'uppercase',
201201
letterSpacing: '0.15em',
@@ -204,7 +204,7 @@ export function DocSearch(props: DocSearchProps) {
204204
'.DocSearch-Hit': {
205205
padding: 0,
206206
a: {
207-
padding: `0 ${Spacing.L}`,
207+
padding: `0 ${Spacing['16px']}`,
208208
borderRadius: BorderRadius.S,
209209
},
210210
'&[aria-selected=true] a': {
@@ -213,10 +213,10 @@ export function DocSearch(props: DocSearchProps) {
213213
},
214214
'.DocSearch-Hit-Container': {
215215
height: 'auto',
216-
padding: `${Spacing.M_L} 0`,
216+
padding: `${Spacing['12px']} 0`,
217217
},
218218
'.DocSearch-Hit-Tree': {
219-
width: Spacing.L,
219+
width: Spacing['16px'],
220220
height: 0,
221221
opacity: 0,
222222
},
@@ -228,19 +228,19 @@ export function DocSearch(props: DocSearchProps) {
228228
},
229229
'.DocSearch-Hit-title': {
230230
fontSize: FontSize['16px'],
231-
fontWeight: FontWeight.Semibold,
231+
fontWeight: FontWeight.SEMIBOLD,
232232
overflow: 'hidden',
233233
textOverflow: 'ellipsis',
234234
},
235235
'.DocSearch-Hit-path': {
236-
marginTop: Spacing.S,
236+
marginTop: Spacing['4px'],
237237
fontSize: FontSize['16px'],
238-
fontWeight: FontWeight.Normal,
238+
fontWeight: FontWeight.REGULAR,
239239
overflow: 'hidden',
240240
textOverflow: 'ellipsis',
241241
},
242242
'.DocSearch-Hit-action': {
243-
marginInlineStart: Spacing.L,
243+
marginInlineStart: Spacing['16px'],
244244
},
245245
'.DocSearch-HitsFooter': {
246246
display: 'none',
@@ -249,7 +249,7 @@ export function DocSearch(props: DocSearchProps) {
249249
position: 'fixed',
250250
bottom: 0,
251251
insetInline: 0,
252-
padding: Spacing.L,
252+
padding: Spacing['16px'],
253253
backgroundColor: 'transparent',
254254
boxShadow: 'none',
255255
'&::before': {
@@ -278,16 +278,16 @@ export function DocSearch(props: DocSearchProps) {
278278
},
279279
'.DocSearch-Screen-Icon': {
280280
padding: 0,
281-
marginBottom: Spacing.L,
281+
marginBottom: Spacing['16px'],
282282
display: 'flex',
283283
justifyContent: 'center',
284284
},
285285
'.DocSearch-NoResults': {
286-
padding: `${Spacing.XXL} 0`,
286+
padding: `${Spacing['64px']} 0`,
287287
},
288288
'.DocSearch-NoResults-Prefill-List': {
289289
padding: 0,
290-
marginTop: Spacing.XL,
290+
marginTop: Spacing['32px'],
291291
textAlign: 'center',
292292
},
293293
})}

0 commit comments

Comments
 (0)