From 9bcb72816febecfb360691f7da415b92e59fe641 Mon Sep 17 00:00:00 2001 From: Dimitri POSTOLOV Date: Mon, 15 Jan 2024 16:43:06 +0100 Subject: [PATCH] fix hidden sidebar (#581) * fix * allright --- website/next.config.js | 29 ++++++++----------- .../ar/developing/supported-networks.mdx | 4 ++- .../cs/developing/supported-networks.mdx | 4 ++- .../de/developing/supported-networks.mdx | 4 ++- .../en/developing/graph-ts/[[...slug]].mdx | 12 +++----- .../en/developing/supported-networks.mdx | 4 ++- .../en/querying/graph-client/[[...slug]].mdx | 12 +++----- .../es/developing/supported-networks.mdx | 4 ++- .../fr/developing/supported-networks.mdx | 4 ++- .../ha/developing/supported-networks.mdx | 4 ++- .../hi/developing/supported-networks.mdx | 4 ++- .../it/developing/supported-networks.mdx | 4 ++- .../ja/developing/supported-networks.mdx | 4 ++- .../ko/developing/supported-networks.mdx | 4 ++- .../mr/developing/supported-networks.mdx | 4 ++- .../nl/developing/supported-networks.mdx | 4 ++- .../pl/developing/supported-networks.mdx | 4 ++- .../pt/developing/supported-networks.mdx | 4 ++- .../ro/developing/supported-networks.mdx | 4 ++- .../ru/developing/supported-networks.mdx | 4 ++- .../sv/developing/supported-networks.mdx | 4 ++- .../tr/developing/supported-networks.mdx | 4 ++- .../uk/developing/supported-networks.mdx | 4 ++- .../ur/developing/supported-networks.mdx | 4 ++- .../vi/developing/supported-networks.mdx | 4 ++- .../yo/developing/supported-networks.mdx | 4 ++- .../zh/developing/supported-networks.mdx | 4 ++- website/src/buildGetStaticProps.ts | 28 +++++++++++------- website/src/remarkReplaceImages.ts | 3 +- website/src/remarkReplaceLinks.ts | 3 +- 30 files changed, 112 insertions(+), 71 deletions(-) diff --git a/website/next.config.js b/website/next.config.js index bfa9dd99445e..9d1581bdfa4b 100644 --- a/website/next.config.js +++ b/website/next.config.js @@ -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' : '', @@ -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', diff --git a/website/pages/ar/developing/supported-networks.mdx b/website/pages/ar/developing/supported-networks.mdx index 8df633d1d26c..33353d1eaa94 100644 --- a/website/pages/ar/developing/supported-networks.mdx +++ b/website/pages/ar/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/cs/developing/supported-networks.mdx b/website/pages/cs/developing/supported-networks.mdx index cd82305bfce2..b9591c2f0afe 100644 --- a/website/pages/cs/developing/supported-networks.mdx +++ b/website/pages/cs/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/de/developing/supported-networks.mdx b/website/pages/de/developing/supported-networks.mdx index cd82305bfce2..b9591c2f0afe 100644 --- a/website/pages/de/developing/supported-networks.mdx +++ b/website/pages/de/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/en/developing/graph-ts/[[...slug]].mdx b/website/pages/en/developing/graph-ts/[[...slug]].mdx index af90e33cc3d4..5caa2942a740 100644 --- a/website/pages/en/developing/graph-ts/[[...slug]].mdx +++ b/website/pages/en/developing/graph-ts/[[...slug]].mdx @@ -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' @@ -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)) @@ -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/' }], ], @@ -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}`, }, } -} +}) diff --git a/website/pages/en/developing/supported-networks.mdx b/website/pages/en/developing/supported-networks.mdx index cd82305bfce2..b9591c2f0afe 100644 --- a/website/pages/en/developing/supported-networks.mdx +++ b/website/pages/en/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/en/querying/graph-client/[[...slug]].mdx b/website/pages/en/querying/graph-client/[[...slug]].mdx index 8bc7824364ee..bf7d4dd4d9d8 100644 --- a/website/pages/en/querying/graph-client/[[...slug]].mdx +++ b/website/pages/en/querying/graph-client/[[...slug]].mdx @@ -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' @@ -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)) @@ -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/' }], ], @@ -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}`, }, } -} +}) diff --git a/website/pages/es/developing/supported-networks.mdx b/website/pages/es/developing/supported-networks.mdx index d5eb03190a1c..0c2d9107a71a 100644 --- a/website/pages/es/developing/supported-networks.mdx +++ b/website/pages/es/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/fr/developing/supported-networks.mdx b/website/pages/fr/developing/supported-networks.mdx index 81cdce0b418b..8e804de06bf7 100644 --- a/website/pages/fr/developing/supported-networks.mdx +++ b/website/pages/fr/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/ha/developing/supported-networks.mdx b/website/pages/ha/developing/supported-networks.mdx index cd82305bfce2..b9591c2f0afe 100644 --- a/website/pages/ha/developing/supported-networks.mdx +++ b/website/pages/ha/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/hi/developing/supported-networks.mdx b/website/pages/hi/developing/supported-networks.mdx index cf872395ac16..ac89ceb33809 100644 --- a/website/pages/hi/developing/supported-networks.mdx +++ b/website/pages/hi/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/it/developing/supported-networks.mdx b/website/pages/it/developing/supported-networks.mdx index 08c9df030c11..7353acce9266 100644 --- a/website/pages/it/developing/supported-networks.mdx +++ b/website/pages/it/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/ja/developing/supported-networks.mdx b/website/pages/ja/developing/supported-networks.mdx index ca23a5cf4c2e..99ab5ef5310b 100644 --- a/website/pages/ja/developing/supported-networks.mdx +++ b/website/pages/ja/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/ko/developing/supported-networks.mdx b/website/pages/ko/developing/supported-networks.mdx index 4719cd60efe4..e5ead4333063 100644 --- a/website/pages/ko/developing/supported-networks.mdx +++ b/website/pages/ko/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/mr/developing/supported-networks.mdx b/website/pages/mr/developing/supported-networks.mdx index d033eeecc766..9dd230b7d594 100644 --- a/website/pages/mr/developing/supported-networks.mdx +++ b/website/pages/mr/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/nl/developing/supported-networks.mdx b/website/pages/nl/developing/supported-networks.mdx index cd82305bfce2..b9591c2f0afe 100644 --- a/website/pages/nl/developing/supported-networks.mdx +++ b/website/pages/nl/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/pl/developing/supported-networks.mdx b/website/pages/pl/developing/supported-networks.mdx index 7ebc9a3bf6cf..4d0cedc7bdbf 100644 --- a/website/pages/pl/developing/supported-networks.mdx +++ b/website/pages/pl/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/pt/developing/supported-networks.mdx b/website/pages/pt/developing/supported-networks.mdx index d73a47daf437..3948903ac1cc 100644 --- a/website/pages/pt/developing/supported-networks.mdx +++ b/website/pages/pt/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/ro/developing/supported-networks.mdx b/website/pages/ro/developing/supported-networks.mdx index 335f07c18968..1ea9aa1e5817 100644 --- a/website/pages/ro/developing/supported-networks.mdx +++ b/website/pages/ro/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/ru/developing/supported-networks.mdx b/website/pages/ru/developing/supported-networks.mdx index daba34911b4b..65bde55808eb 100644 --- a/website/pages/ru/developing/supported-networks.mdx +++ b/website/pages/ru/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/sv/developing/supported-networks.mdx b/website/pages/sv/developing/supported-networks.mdx index 83d9fdfc287f..26ef1d6a9d03 100644 --- a/website/pages/sv/developing/supported-networks.mdx +++ b/website/pages/sv/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/tr/developing/supported-networks.mdx b/website/pages/tr/developing/supported-networks.mdx index 8d710a33a098..875b41db6f88 100644 --- a/website/pages/tr/developing/supported-networks.mdx +++ b/website/pages/tr/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/uk/developing/supported-networks.mdx b/website/pages/uk/developing/supported-networks.mdx index 398b3257db7a..b24edb261557 100644 --- a/website/pages/uk/developing/supported-networks.mdx +++ b/website/pages/uk/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/ur/developing/supported-networks.mdx b/website/pages/ur/developing/supported-networks.mdx index dee72d2419e3..3bfe65e7b015 100644 --- a/website/pages/ur/developing/supported-networks.mdx +++ b/website/pages/ur/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/vi/developing/supported-networks.mdx b/website/pages/vi/developing/supported-networks.mdx index 8cc8159f29f4..da2beb6bfeb9 100644 --- a/website/pages/vi/developing/supported-networks.mdx +++ b/website/pages/vi/developing/supported-networks.mdx @@ -2,9 +2,11 @@ title: Các mạng được hỗ trợ --- -export { getStaticPropsForSupportedNetworks as getStaticProps } from '@/src/buildGetStaticProps' +import { getStaticPropsForSupportedNetworks } from '@/src/buildGetStaticProps' import { SupportedNetworksTable } from '@/src/supportedNetworks' +export const getStaticProps = getStaticPropsForSupportedNetworks(__filename) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/yo/developing/supported-networks.mdx b/website/pages/yo/developing/supported-networks.mdx index cd82305bfce2..b9591c2f0afe 100644 --- a/website/pages/yo/developing/supported-networks.mdx +++ b/website/pages/yo/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/pages/zh/developing/supported-networks.mdx b/website/pages/zh/developing/supported-networks.mdx index c0bced3ae466..a90169af6a30 100644 --- a/website/pages/zh/developing/supported-networks.mdx +++ b/website/pages/zh/developing/supported-networks.mdx @@ -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) + The hosted service relies on the stability and reliability of the underlying technologies, namely the provided JSON RPC endpoints. diff --git a/website/src/buildGetStaticProps.ts b/website/src/buildGetStaticProps.ts index 712b519d063c..7efb548902af 100644 --- a/website/src/buildGetStaticProps.ts +++ b/website/src/buildGetStaticProps.ts @@ -1,30 +1,38 @@ +import path from 'path' + import { GetStaticProps, GetStaticPropsResult } from 'next' +import { Locale } from '@edgeandnode/gds' + import { getPageMap } from '@/src/getPageMap' import { getSupportedNetworks } from '@/src/supportedNetworks' -export const buildGetStaticProps = (overrides?: GetStaticProps) => { +export const buildGetStaticProps = (fileName: string, overrides?: GetStaticProps) => { const getStaticProps: GetStaticProps = async (context) => { const overrideStaticProps: GetStaticPropsResult> = overrides ? await overrides(context) : { props: {} } + const pagesDir = path.join(process.cwd(), '.next', 'server', 'pages') + const pagePath = path.relative(pagesDir, fileName) + const locale = pagePath.slice(0, 2) as Locale + return { ...overrideStaticProps, props: { ...('props' in overrideStaticProps && overrideStaticProps.props), - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - __nextra_pageMap: await getPageMap(globalThis.__graph_docs_locale), + __nextra_pageMap: await getPageMap(locale), }, } } return getStaticProps } -export const getStaticPropsForSupportedNetworks = buildGetStaticProps(async () => { - return { - props: { - networks: await getSupportedNetworks(), - }, - } -}) +export const getStaticPropsForSupportedNetworks = (fileName: string) => + buildGetStaticProps(fileName, async () => { + return { + props: { + networks: await getSupportedNetworks(), + }, + } + }) diff --git a/website/src/remarkReplaceImages.ts b/website/src/remarkReplaceImages.ts index d75266089a03..f642822f7990 100644 --- a/website/src/remarkReplaceImages.ts +++ b/website/src/remarkReplaceImages.ts @@ -5,7 +5,7 @@ import { visit } from 'unist-util-visit' export const remarkReplaceImages: Plugin<[{ assetsBasePath: string }], Root> = ({ assetsBasePath }) => { if (!assetsBasePath) throw new Error('remarkReplaceImages: assetsBasePath is required') - return (tree, _file, done) => { + return (tree, _file) => { visit( tree, [ @@ -28,6 +28,5 @@ export const remarkReplaceImages: Plugin<[{ assetsBasePath: string }], Root> = ( node.url = node.url.replace(/.*\.\.\/assets\//, `https://raw.githubusercontent.com/${assetsBasePath}assets/`) } }) - done() } } diff --git a/website/src/remarkReplaceLinks.ts b/website/src/remarkReplaceLinks.ts index 5fb2a5d66bb5..96181a7dc333 100644 --- a/website/src/remarkReplaceLinks.ts +++ b/website/src/remarkReplaceLinks.ts @@ -11,7 +11,7 @@ export const remarkReplaceLinks: Plugin<[{ foundPath: string; basePath: string } if (!foundPath) throw new Error('remarkReplaceLinks: foundPath is required') if (!basePath) throw new Error('remarkReplaceLinks: basePath is required') - return (tree, _file, done) => { + return (tree, _file) => { // Rewrite relative links to ensure they work visit(tree, 'link', (node) => { // Skip external links and same-page anchor links @@ -26,6 +26,5 @@ export const remarkReplaceLinks: Plugin<[{ foundPath: string; basePath: string } node.url = path.join(basePath + path.dirname(foundPath), node.url) } }) - done() } }