Skip to content

Commit

Permalink
fix hidden sidebar (#581)
Browse files Browse the repository at this point in the history
* fix

* allright
  • Loading branch information
Dimitri POSTOLOV authored Jan 15, 2024
1 parent 3b3662a commit 9bcb728
Show file tree
Hide file tree
Showing 30 changed files with 112 additions and 71 deletions.
29 changes: 12 additions & 17 deletions website/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import nextra from 'nextra'

import { defaultLocale, extractLocaleFromPath } from '@edgeandnode/gds'

const env = {
ENVIRONMENT: process.env.ENVIRONMENT,
BASE_PATH: process.env.NODE_ENV === 'production' ? '/docs' : '',
Expand All @@ -23,27 +21,24 @@ const withNextra = nextra({
codeHighlight: false,
defaultShowCopyCode: false,
transform(result, { route }) {
if (!route) return result

const { locale } = extractLocaleFromPath(route)
if (route && !result.includes('getStaticProps')) {
const banner = `
import { getPageMap } from '@/src/getPageMap'
result = `
globalThis.__graph_docs_locale = '${locale ?? defaultLocale}'
${result}
`

if (!result.includes('getStaticProps')) {
result = `
import { buildGetStaticProps } from '@/src/buildGetStaticProps'
${result}
export const getStaticProps = buildGetStaticProps()
`
export const getStaticProps = async context => ({
props: {
__nextra_pageMap: await getPageMap('${route.split('/')[1]}')
}
})`
result += banner
}

return result
},
})

/**
* @type {import('next').NextConfig}
*/
export default withNextra({
env,
output: 'export',
Expand Down
4 changes: 3 additions & 1 deletion website/pages/ar/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: الشبكات المدعومة
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/cs/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Supported Networks
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/de/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Supported Networks
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
12 changes: 4 additions & 8 deletions website/pages/en/developing/graph-ts/[[...slug]].mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RemoteContent } from 'nextra/data'
import { buildDynamicMDX } from 'nextra/remote'
import { getPageMap } from '@/src/getPageMap'
import { buildGetStaticProps } from '@/src/buildGetStaticProps'
import { remarkReplaceLinks } from '@/src/remarkReplaceLinks'
import { Mermaid } from 'nextra/components'
import { visit } from 'unist-util-visit'
Expand All @@ -15,9 +15,7 @@ export const getStaticPaths = () => ({
})),
})

{/* Only in dynamic route we can't use `buildGetStaticProps` function, because route is based on filename of mdx page */}

export async function getStaticProps({ params }) {
export const getStaticProps = buildGetStaticProps(__filename, async ({ params }) => {
const { filePaths, user, repo, branch, docsPath } = json
const paths = params?.slug?.join('/')
const foundPath = filePaths.find((filePath) => filePath.startsWith(paths))
Expand All @@ -28,13 +26,12 @@ export async function getStaticProps({ params }) {
mdxOptions: {
format: 'md',
remarkPlugins: [
() => (tree, _file, done) => {
() => (tree, _file) => {
visit(tree, 'link', (node) => {
if (node.url.startsWith('../')) {
node.url = node.url.replace('../', `https://github.com/${user}/${repo}/tree/${branch}/`)
}
})
done()
},
[remarkReplaceLinks, { foundPath, basePath: '/developing/graph-ts/' }],
],
Expand All @@ -44,11 +41,10 @@ export async function getStaticProps({ params }) {
return {
props: {
...mdx,
__nextra_pageMap: await getPageMap('en'),
hideLocaleSwitcher: true,
remoteFilePath: `https://github.com/${user}/${repo}/tree/${branch}/${docsPath}${foundPath}`,
},
}
}
})

<RemoteContent components={{ Mermaid }} />
4 changes: 3 additions & 1 deletion website/pages/en/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Supported Networks
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
12 changes: 4 additions & 8 deletions website/pages/en/querying/graph-client/[[...slug]].mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RemoteContent } from 'nextra/data'
import { buildDynamicMDX } from 'nextra/remote'
import { getPageMap } from '@/src/getPageMap'
import { buildGetStaticProps } from '@/src/buildGetStaticProps'
import { remarkReplaceLinks } from '@/src/remarkReplaceLinks'
import { Mermaid } from 'nextra/components'
import { visit } from 'unist-util-visit'
Expand All @@ -15,9 +15,7 @@ export const getStaticPaths = () => ({
})),
})

{/* Only in dynamic route we can't use `buildGetStaticProps` function, because route is based on filename of mdx page */}

export async function getStaticProps({ params }) {
export const getStaticProps = buildGetStaticProps(__filename, async ({ params }) => {
const { filePaths, user, repo, branch, docsPath } = json
const paths = params?.slug?.join('/')
const foundPath = filePaths.find((filePath) => filePath.startsWith(paths))
Expand All @@ -28,13 +26,12 @@ export async function getStaticProps({ params }) {
mdxOptions: {
format: 'md',
remarkPlugins: [
() => (tree, _file, done) => {
() => (tree, _file) => {
visit(tree, 'link', (node) => {
if (node.url.startsWith('../')) {
node.url = node.url.replace('../', `https://github.com/${user}/${repo}/tree/${branch}/`)
}
})
done()
},
[remarkReplaceLinks, { foundPath, basePath: '/querying/graph-client/' }],
],
Expand All @@ -44,11 +41,10 @@ export async function getStaticProps({ params }) {
return {
props: {
...mdx,
__nextra_pageMap: await getPageMap('en'),
hideLocaleSwitcher: true,
remoteFilePath: `https://github.com/${user}/${repo}/tree/${branch}/${docsPath}${foundPath}`,
},
}
}
})

<RemoteContent components={{ Mermaid }} />
4 changes: 3 additions & 1 deletion website/pages/es/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Redes admitidas
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/fr/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Réseaux supportés
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/ha/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Supported Networks
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/hi/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: समर्थित नेटवर्क्स
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/it/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Reti supportate
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/ja/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: サポートされているネットワーク
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/ko/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: 지원되는 네트워크들
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/mr/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: समर्थित नेटवर्क
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/nl/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Supported Networks
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/pl/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Wspierane sieci
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/pt/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Redes Apoiadas
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/ro/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Rețele suportate
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/ru/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Поддерживаемые сети
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/sv/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Stödda Nätverk
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
4 changes: 3 additions & 1 deletion website/pages/tr/developing/supported-networks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Desteklenen Ağlar
---

export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps'
import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps'
import { SupportedNetworksTable } from '@/src/supportedNetworks'

export const getStaticProps = getStaticPropsForSupportedNetworks(__filename)

<SupportedNetworksTable networks={props.networks} />

The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints.
Expand Down
Loading

0 comments on commit 9bcb728

Please sign in to comment.