diff --git a/website/mdx-components.js b/website/mdx-components.js new file mode 100644 index 0000000000000..4caafad8b8d53 --- /dev/null +++ b/website/mdx-components.js @@ -0,0 +1,6 @@ +import { useMDXComponents as getDocsMDXComponents } from '@theguild/components/server'; +import { docsMDXComponents } from './src/components/docs-mdx-components'; + +export const useMDXComponents = () => { + return getDocsMDXComponents(docsMDXComponents); +}; diff --git a/website/next-env.d.ts b/website/next-env.d.ts index 52e831b434248..1b3be0840f3f6 100644 --- a/website/next-env.d.ts +++ b/website/next-env.d.ts @@ -2,4 +2,4 @@ /// // NOTE: This file should not be edited -// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information. +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/website/next.config.js b/website/next.config.js index 60499530268c4..c190fc6ac8dc4 100644 --- a/website/next.config.js +++ b/website/next.config.js @@ -6,6 +6,11 @@ export default withGuildDocs({ eslint: { ignoreDuringBuilds: true, }, + experimental: { + turbo: { + treeShaking: true, + }, + }, redirects: () => Object.entries({ '/api': '/docs', diff --git a/website/package.json b/website/package.json index cb023bac91ed6..4cf72bd3ac0c8 100644 --- a/website/package.json +++ b/website/package.json @@ -6,13 +6,15 @@ "scripts": { "analyze": "cross-env ANALYZE=true next build", "build": "next build && next-sitemap", - "dev": "next", + "dev": "next --turbopack", + "postbuild": "pagefind --site .next/server/app --output-path out/_pagefind", "start": "next start" }, "dependencies": { "@theguild/components": "^8.0.0", "next": "^15.0.0", "next-sitemap": "^4.2.3", + "pagefind": "^1.2.0", "react": "^19.0.0", "react-dom": "^19.0.0", "react-icons": "^5.0.0" diff --git a/website/src/app/(content-pages)/docs/[[...mdxPath]]/legacy-docs-banner.tsx b/website/src/app/(content-pages)/docs/[[...mdxPath]]/legacy-docs-banner.tsx new file mode 100644 index 0000000000000..c7f23c78bd0e5 --- /dev/null +++ b/website/src/app/(content-pages)/docs/[[...mdxPath]]/legacy-docs-banner.tsx @@ -0,0 +1,26 @@ +'use client'; + +import { usePathname } from 'next/navigation'; +import { Callout } from '@theguild/components'; +import { Link } from '../../../../components/docs-mdx-components'; + +export function LegacyDocsBanner() { + const pathname = usePathname(); + if (pathname.startsWith('/v1')) { + return null; + } + + return ( + + This is the documentation for the old GraphQL Mesh version v0. We recommend upgrading + to the latest GraphQL Mesh version v1. +
+ + Migrate to GraphQL Mesh v1 + +
+ ); +} diff --git a/website/src/app/(content-pages)/docs/[[...mdxPath]]/page.tsx b/website/src/app/(content-pages)/docs/[[...mdxPath]]/page.tsx new file mode 100644 index 0000000000000..a89a8c14c32c1 --- /dev/null +++ b/website/src/app/(content-pages)/docs/[[...mdxPath]]/page.tsx @@ -0,0 +1,42 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import { generateStaticParamsFor, importPage } from 'nextra/pages'; +import { NextPageProps } from '@theguild/components'; +import { useMDXComponents } from '../../../../../mdx-components.js'; +import { ConfiguredGiscus } from '../../../../components/configured-giscus'; +import { LegacyDocsBanner } from './legacy-docs-banner'; + +/** + * You might have an urge to try to refactor this to a separate file and reuse between product-updates and docs. + * I had the same urge. It's absurdly finicky. I warned you. + * + * BTW, even if we moved the product updates to page.mdx pattern, we still need this nesting to fix links in sidebar. + */ +export const generateStaticParams = async () => { + const pages = await generateStaticParamsFor('mdxPath')(); + return pages + .map(page => (page.mdxPath[0] === 'docs' ? { mdxPath: page.mdxPath.slice(1) } : null)) + .filter(Boolean); +}; + +export async function generateMetadata(props: NextPageProps<'...mdxPath'>) { + const params = await props.params; + const { metadata } = await importPage(['docs', ...(params.mdxPath || [])]); + return metadata; +} + +const Wrapper = useMDXComponents().wrapper; + +export default async function Page(props: NextPageProps<'...mdxPath'>) { + const params = await props.params; + + const result = await importPage(['docs', ...(params.mdxPath || [])]); + const { default: MDXContent, toc, metadata } = result; + + return ( + + + + + + ); +} diff --git a/website/src/app/examples.mdx b/website/src/app/(content-pages)/examples/live-demo.tsx similarity index 79% rename from website/src/app/examples.mdx rename to website/src/app/(content-pages)/examples/live-demo.tsx index bbd0f8c694e45..c405a818fc25e 100644 --- a/website/src/app/examples.mdx +++ b/website/src/app/(content-pages)/examples/live-demo.tsx @@ -1,14 +1,9 @@ ---- -title: Examples -description: Examples of Mesh usage ---- +'use client'; -import { useState } from 'react' - - +import { useState } from 'react'; export function LiveDemo() { - const [exampleRepo, setExampleRepo] = useState('json-schema-example') + const [exampleRepo, setExampleRepo] = useState('json-schema-example'); return (
@@ -16,7 +11,7 @@ export function LiveDemo() {