Skip to content

3/4 Refactor _meta.js to prefer sidebarTitle #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

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

109 changes: 67 additions & 42 deletions website/next.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import nextra from 'nextra'
import path from 'node:path'
import { visit } from 'unist-util-visit'

import { translate } from '@edgeandnode/gds'

// Compile `i18n.ts` to `i18n.js` since we can't import `ts` files in `next.config.js`
import { translations } from './dist/i18n.js'
import { remarkReplaceLinks } from './src/remarkReplaceLinks.js'
import { remarkTransformRemoteGitHub } from './src/remarkTransformRemoteGitHub.js'

const env = {
ENVIRONMENT: process.env.ENVIRONMENT,
Expand All @@ -23,56 +21,85 @@ const env = {
}

const withNextra = nextra({
theme: './src/nextra-theme/index.tsx',
theme: './src/NextraLayout.tsx',
search: false,
codeHighlight: false,
defaultShowCopyCode: false,
readingTime: true,
transformPageMap(pageMap) {
const locale = pageMap[0].data.slice(0, 2)
const locale = pageMap[0].route.slice(1, 3)
// TODO: remove this when crowdin will translate global.json
const t = (key) => {
try {
return translate(translations, locale, `global.sidebar.${key}`)
} catch {
return translate(translations, 'en', `global.sidebar.${key}`)
}
}

const metaFile = {
index: t('index'),
'---1': {
type: 'separator',
},
about: '',
network: t('network'),
sunrise: '',
billing: '',
glossary: '',
tokenomics: '',
arbitrum: t('arbitrum'),
'---2': {
type: 'separator',
},
'###1': {
type: 'heading',
title: t('subgraphs'),
},
'quick-start': '',
developing: t('developing'),
deploying: t('deploying'),
publishing: t('publishing'),
managing: t('managing'),
querying: t('querying'),
cookbook: t('cookbook'),
'release-notes': t('releaseNotes'),
'---3': {
type: 'separator',
},
'###2': {
type: 'heading',
title: t('substreams'),
},
substreams: '',
'---4': {
type: 'separator',
},
'###3': {
type: 'heading',
title: t('indexing'),
},
'operating-graph-node': '',
'chain-integration-overview': '',
'supported-network-requirements': '',
'new-chain-integration': '',
firehose: '',
graphcast: '',
'mips-faqs': '',
}

return [
...pageMap,
{ data: metaFile },
{
route: `/${locale}`,
name: 'index',
frontMatter: {
title: translate(translations, locale, 'index.title'),
},
frontMatter: {},
},
...pageMap,
]
},
mdxOptions: {
remarkPlugins: [
() => (tree, file) => {
const filePath = path.relative(process.cwd(), file.history[0])
const [fileName, directory] = filePath.split('/').reverse()

let user
let repo
let branch
let basePath
if (directory === 'graph-ts') {
user = 'graphprotocol'
repo = 'graph-tooling'
branch = 'main'
basePath = '/developing/graph-ts/'
} else if (directory === 'graph-client') {
user = 'graphprotocol'
repo = 'graph-client'
branch = 'main'
basePath = '/querying/graph-client/'
}
if (user) {
visit(tree, 'link', (node) => {
if (node.url.startsWith('../')) {
const GO_BACK_REPEATED_REGEX = /(\.\.\/)+/
node.url = node.url.replace(GO_BACK_REPEATED_REGEX, `https://github.com/${user}/${repo}/tree/${branch}/`)
}
})
remarkReplaceLinks({ foundPath: fileName, basePath })(tree, file)
}
},
],
remarkPlugins: [remarkTransformRemoteGitHub],
},
})

Expand Down Expand Up @@ -147,8 +174,6 @@ export default withNextra({
'ur',
'vi',
'zh',
// I added new lang otherwise build fails with
// Module not found: Can't resolve '/Users/dmytro/Desktop/GUILD/graph-docs/website/.next/static/chunks/nextra-page-map-ro.mjs'
'cs',
'ha',
'ro',
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"next": "^14.2.5",
"next-seo": "^6.5.0",
"next-sitemap": "^4.2.3",
"nextra": "^3.0.0-alpha.30",
"nextra": "^3.0.0-alpha.31",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-ga4": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion website/pages/[locale]/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getStaticPaths = () => {
export const getStaticProps = async ({ params: { locale } }) => {
const t = (key) => translate(translations, locale, key)
const rawMdx = `---
title: ${t('index.title')}
title: ${t('global.sidebar.index')}
---
${t('index.intro')}
<Intro />
Expand Down
4 changes: 2 additions & 2 deletions website/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {
import { CookieBanner, GlobalFooter, GlobalHeader } from '@edgeandnode/go'

import { supportedLocales, translations, useI18n } from '@/i18n'
import { DocSearch } from '@/src/nextra-theme/components'
import { DocSearch } from '@/src/components'

import '@edgeandnode/gds/style.css'
import '@docsearch/css'
import '../src/app.css'
import './globals.css'

const internalAbsoluteHrefRegex = /^(((https?:)?\/\/((www|staging)\.)?thegraph\.com)?\/docs\/|\/(?!\/))/i
const externalHrefRegex = /^(?!(https?:)?\/\/((www|staging)\.)?thegraph\.com)([a-zA-Z0-9+.-]+:)?\/\//i
Expand Down
5 changes: 0 additions & 5 deletions website/pages/ar/_meta.js

This file was deleted.

5 changes: 4 additions & 1 deletion website/pages/ar/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"notFoundTitle": "عفوا! هذه الصفحة ضاعت في الفضاء...",
"notFoundSubtitle": "تحقق مما إذا كنت تستخدم العنوان الصحيح أو استكشف موقعنا على الويب من خلال النقر على الرابط أدناه.",
"goHome": "الذهاب للرئيسية",
"video": "Video"
"video": "Video",
"sidebar": {
"index": "البدء"
}
}
1 change: 0 additions & 1 deletion website/pages/ar/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "البدء",
"intro": "تعرف على The Graph ، وهو بروتوكول لامركزي لفهرسة البيانات والاستعلام عنها من ال Blockchains.",
"shortcuts": {
"aboutTheGraph": {
Expand Down
5 changes: 0 additions & 5 deletions website/pages/cs/_meta.js

This file was deleted.

5 changes: 4 additions & 1 deletion website/pages/cs/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"notFoundTitle": "Oops! This page was lost in space...",
"notFoundSubtitle": "Check if you’re using the right address or explore our website by clicking on the link below.",
"goHome": "Go Home",
"video": "Video"
"video": "Video",
"sidebar": {
"index": "Začněte"
}
}
1 change: 0 additions & 1 deletion website/pages/cs/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Začněte",
"intro": "Seznamte se s Grafu, decentralizovaným protokolem pro indexování a dotazování dat z blockchainů.",
"shortcuts": {
"aboutTheGraph": {
Expand Down
5 changes: 0 additions & 5 deletions website/pages/de/_meta.js

This file was deleted.

5 changes: 4 additions & 1 deletion website/pages/de/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"notFoundTitle": "Ups! Diese Seite ging im Weltraum verloren...",
"notFoundSubtitle": "Überprüfen Sie, ob Sie die richtige Adresse verwenden, oder besuchen Sie unsere Website, indem Sie auf den unten stehenden Link klicken.",
"goHome": "Zurück zur Startseite",
"video": "Video"
"video": "Video",
"sidebar": {
"index": "Get Started"
}
}
1 change: 0 additions & 1 deletion website/pages/de/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Get Started",
"intro": "Learn about The Graph, a decentralized protocol for indexing and querying data from blockchains.",
"shortcuts": {
"aboutTheGraph": {
Expand Down
50 changes: 0 additions & 50 deletions website/pages/en/_meta.js

This file was deleted.

4 changes: 2 additions & 2 deletions website/pages/en/developing/graph-ts/_meta.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
README: 'Introduction',
api: 'API Reference',
'common-issues': 'Common Issues',
api: '',
'common-issues': '',
}
1 change: 1 addition & 0 deletions website/pages/en/developing/graph-ts/api.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: AssemblyScript API
sidebarTitle: API Reference
---

> Note: if you created a subgraph prior to `graph-cli`/`graph-ts` version `0.22.0`, you're using an older version of AssemblyScript, we recommend taking a look at the [`Migration Guide`](/release-notes/assemblyscript-migration-guide)
Expand Down
1 change: 1 addition & 0 deletions website/pages/en/developing/graph-ts/common-issues.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Common AssemblyScript Issues
sidebarTitle: Common Issues
---

There are certain [AssemblyScript](https://github.com/AssemblyScript/assemblyscript) issues that are common to run into during subgraph development. They range in debug difficulty, however, being aware of them may help. The following is a non-exhaustive list of these issues:
Expand Down
17 changes: 16 additions & 1 deletion website/pages/en/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,20 @@
"notFoundTitle": "Oops! This page was lost in space...",
"notFoundSubtitle": "Check if you’re using the right address or explore our website by clicking on the link below.",
"goHome": "Go Home",
"video": "Video"
"video": "Video",
"sidebar": {
"index": "Get Started",
"network": "The Graph Network",
"arbitrum": "Scaling with Arbitrum",
"subgraphs": "Subgraphs",
"developing": "Developing",
"deploying": "Deploying",
"publishing": "Publishing",
"managing": "Managing",
"querying": "Querying",
"cookbook": "Cookbook",
"releaseNotes": "Release Notes & Upgrade Guides",
"substreams": "Substreams",
"indexing": "Indexing"
}
}
1 change: 0 additions & 1 deletion website/pages/en/index.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"title": "Get Started",
"intro": "Learn about The Graph, a decentralized protocol for indexing and querying data from blockchains.",
"shortcuts": {
"aboutTheGraph": {
Expand Down
22 changes: 0 additions & 22 deletions website/pages/es/_meta.js

This file was deleted.

Loading
Loading