Skip to content

Commit b361735

Browse files
dimaMachinabenface
andauthored
3/4 Refactor _meta.js to prefer sidebarTitle (#733)
* move mdxStyles * more * more * more * more * more * more * more * more * more * more * more * more * more * more * more * more * more * more * more * more * lint * update nextra * 4/4 move `pages` to `src/pages` (#734) * move pages to src * some refactoring * Update Node * Remove unneeded `try…catch` * `pnpm check:fix` --------- Co-authored-by: benface <[email protected]>
1 parent 45e1d66 commit b361735

File tree

1,807 files changed

+388
-509
lines changed

Some content is hidden

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

1,807 files changed

+388
-509
lines changed

.eslintrc.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ module.exports = {
2121
// Only lint the English pages because the Markdown for the other languages is auto-generated from English (via Crowdin).
2222
// But include all languages when running the ESLint extension in VS Code (in case the user has "eslint.validate": ["mdx"]),
2323
// otherwise there will be random errors since the non-English files don't match any ruleset.
24-
files: [`website/pages/${isVSCode ? '' : 'en/'}**/*.{md,mdx}`],
24+
files: [`website/src/pages/${isVSCode ? '' : 'en/'}**/*.{md,mdx}`],
2525
excludedFiles: [
26-
`website/pages/${isVSCode ? '' : 'en/'}developing/graph-ts/*.md`,
27-
`website/pages/${isVSCode ? '' : 'en/'}querying/graph-client/*.md`,
26+
`website/src/pages/${isVSCode ? '' : 'en/'}developing/graph-ts/*.md`,
27+
`website/src/pages/${isVSCode ? '' : 'en/'}querying/graph-client/*.md`,
2828
],
2929
parser: 'eslint-mdx',
3030
processor: 'mdx/remark',

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.5.1
1+
22.6.0

.prettierignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ dist/
66
website/.graphclient/
77

88
# ignore below md since they are fetched from GitHub
9-
website/pages/en/developing/graph-ts/*.md
10-
website/pages/en/querying/graph-client/*.md
9+
website/src/pages/en/developing/graph-ts/*.md
10+
website/src/pages/en/querying/graph-client/*.md

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/i18n.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import { Locale, type NestedStrings, type Translations, useI18n as _useI18n } from '@edgeandnode/gds'
22

3-
import ar from '@/pages/ar/translations'
4-
import cs from '@/pages/cs/translations'
5-
import de from '@/pages/de/translations'
6-
import en from '@/pages/en/translations'
7-
import es from '@/pages/es/translations'
8-
import fr from '@/pages/fr/translations'
9-
import ha from '@/pages/ha/translations'
10-
import hi from '@/pages/hi/translations'
11-
import it from '@/pages/it/translations'
12-
import ja from '@/pages/ja/translations'
13-
import ko from '@/pages/ko/translations'
14-
import mr from '@/pages/mr/translations'
15-
import nl from '@/pages/nl/translations'
16-
import pl from '@/pages/pl/translations'
17-
import pt from '@/pages/pt/translations'
18-
import ro from '@/pages/ro/translations'
19-
import ru from '@/pages/ru/translations'
20-
import sv from '@/pages/sv/translations'
21-
import tr from '@/pages/tr/translations'
22-
import uk from '@/pages/uk/translations'
23-
import ur from '@/pages/ur/translations'
24-
import vi from '@/pages/vi/translations'
25-
import yo from '@/pages/yo/translations'
26-
import zh from '@/pages/zh/translations'
3+
import ar from '@/src/pages/ar/translations'
4+
import cs from '@/src/pages/cs/translations'
5+
import de from '@/src/pages/de/translations'
6+
import en from '@/src/pages/en/translations'
7+
import es from '@/src/pages/es/translations'
8+
import fr from '@/src/pages/fr/translations'
9+
import ha from '@/src/pages/ha/translations'
10+
import hi from '@/src/pages/hi/translations'
11+
import it from '@/src/pages/it/translations'
12+
import ja from '@/src/pages/ja/translations'
13+
import ko from '@/src/pages/ko/translations'
14+
import mr from '@/src/pages/mr/translations'
15+
import nl from '@/src/pages/nl/translations'
16+
import pl from '@/src/pages/pl/translations'
17+
import pt from '@/src/pages/pt/translations'
18+
import ro from '@/src/pages/ro/translations'
19+
import ru from '@/src/pages/ru/translations'
20+
import sv from '@/src/pages/sv/translations'
21+
import tr from '@/src/pages/tr/translations'
22+
import uk from '@/src/pages/uk/translations'
23+
import ur from '@/src/pages/ur/translations'
24+
import vi from '@/src/pages/vi/translations'
25+
import yo from '@/src/pages/yo/translations'
26+
import zh from '@/src/pages/zh/translations'
2727

2828
const appLocales = [
2929
Locale.ARABIC,

website/next.config.js

Lines changed: 61 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import nextra from 'nextra'
2-
import path from 'node:path'
3-
import { visit } from 'unist-util-visit'
42

53
import { translate } from '@edgeandnode/gds'
64

75
// Compile `i18n.ts` to `i18n.js` since we can't import `ts` files in `next.config.js`
86
import { translations } from './dist/i18n.js'
9-
import { remarkReplaceLinks } from './src/remarkReplaceLinks.js'
7+
import { remarkTransformRemoteGitHub } from './src/remarkTransformRemoteGitHub.js'
108

119
const env = {
1210
ENVIRONMENT: process.env.ENVIRONMENT,
@@ -23,56 +21,78 @@ const env = {
2321
}
2422

2523
const withNextra = nextra({
26-
theme: './src/nextra-theme/index.tsx',
24+
theme: './src/NextraLayout.tsx',
2725
search: false,
2826
codeHighlight: false,
2927
defaultShowCopyCode: false,
3028
readingTime: true,
3129
transformPageMap(pageMap) {
32-
const locale = pageMap[0].data.slice(0, 2)
30+
const locale = pageMap[0].route.slice(1, 3)
31+
const t = (key) => translate(translations, locale, `global.sidebar.${key}`)
32+
33+
const metaFile = {
34+
index: t('index'),
35+
'---1': {
36+
type: 'separator',
37+
},
38+
about: '',
39+
network: t('network'),
40+
sunrise: '',
41+
billing: '',
42+
glossary: '',
43+
tokenomics: '',
44+
arbitrum: t('arbitrum'),
45+
'---2': {
46+
type: 'separator',
47+
},
48+
'###1': {
49+
type: 'heading',
50+
title: t('subgraphs'),
51+
},
52+
'quick-start': '',
53+
developing: t('developing'),
54+
deploying: t('deploying'),
55+
publishing: t('publishing'),
56+
managing: t('managing'),
57+
querying: t('querying'),
58+
cookbook: t('cookbook'),
59+
'release-notes': t('releaseNotes'),
60+
'---3': {
61+
type: 'separator',
62+
},
63+
'###2': {
64+
type: 'heading',
65+
title: t('substreams'),
66+
},
67+
substreams: '',
68+
'---4': {
69+
type: 'separator',
70+
},
71+
'###3': {
72+
type: 'heading',
73+
title: t('indexing'),
74+
},
75+
'operating-graph-node': '',
76+
'chain-integration-overview': '',
77+
'supported-network-requirements': '',
78+
'new-chain-integration': '',
79+
firehose: '',
80+
graphcast: '',
81+
'mips-faqs': '',
82+
}
83+
3384
return [
34-
...pageMap,
85+
{ data: metaFile },
3586
{
3687
route: `/${locale}`,
3788
name: 'index',
38-
frontMatter: {
39-
title: translate(translations, locale, 'index.title'),
40-
},
89+
frontMatter: {},
4190
},
91+
...pageMap,
4292
]
4393
},
4494
mdxOptions: {
45-
remarkPlugins: [
46-
() => (tree, file) => {
47-
const filePath = path.relative(process.cwd(), file.history[0])
48-
const [fileName, directory] = filePath.split('/').reverse()
49-
50-
let user
51-
let repo
52-
let branch
53-
let basePath
54-
if (directory === 'graph-ts') {
55-
user = 'graphprotocol'
56-
repo = 'graph-tooling'
57-
branch = 'main'
58-
basePath = '/developing/graph-ts/'
59-
} else if (directory === 'graph-client') {
60-
user = 'graphprotocol'
61-
repo = 'graph-client'
62-
branch = 'main'
63-
basePath = '/querying/graph-client/'
64-
}
65-
if (user) {
66-
visit(tree, 'link', (node) => {
67-
if (node.url.startsWith('../')) {
68-
const GO_BACK_REPEATED_REGEX = /(\.\.\/)+/
69-
node.url = node.url.replace(GO_BACK_REPEATED_REGEX, `https://github.com/${user}/${repo}/tree/${branch}/`)
70-
}
71-
})
72-
remarkReplaceLinks({ foundPath: fileName, basePath })(tree, file)
73-
}
74-
},
75-
],
95+
remarkPlugins: [remarkTransformRemoteGitHub],
7696
},
7797
})
7898

@@ -126,33 +146,6 @@ export default withNextra({
126146
},
127147
i18n: {
128148
defaultLocale: 'en',
129-
locales: [
130-
'ar',
131-
'de',
132-
'en',
133-
'es',
134-
'fr',
135-
'hi',
136-
'it',
137-
'ja',
138-
'ko',
139-
'mr',
140-
'nl',
141-
'pl',
142-
'pt',
143-
'ru',
144-
'sv',
145-
'tr',
146-
'uk',
147-
'ur',
148-
'vi',
149-
'zh',
150-
// I added new lang otherwise build fails with
151-
// Module not found: Can't resolve '/Users/dmytro/Desktop/GUILD/graph-docs/website/.next/static/chunks/nextra-page-map-ro.mjs'
152-
'cs',
153-
'ha',
154-
'ro',
155-
'yo',
156-
],
149+
locales: Object.keys(translations),
157150
},
158151
})

website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"next": "^14.2.5",
2929
"next-seo": "^6.5.0",
3030
"next-sitemap": "^4.2.3",
31-
"nextra": "^3.0.0-alpha.30",
31+
"nextra": "^3.0.0-alpha.31",
3232
"react": "^18.3.1",
3333
"react-dom": "^18.3.1",
3434
"react-ga4": "^2.1.0",

website/pages/ar/_meta.js

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

website/pages/cs/_meta.js

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

website/pages/de/_meta.js

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

0 commit comments

Comments
 (0)