Skip to content
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

Nextra 4 Migration 3: layouts and fixes #8118

Open
wants to merge 22 commits into
base: rebranding-2-nextra-4-filemoves
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 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
6 changes: 6 additions & 0 deletions website/mdx-components.js
Original file line number Diff line number Diff line change
@@ -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);
};
2 changes: 1 addition & 1 deletion website/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// 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.
6 changes: 6 additions & 0 deletions website/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export default withGuildDocs({
eslint: {
ignoreDuringBuilds: true,
},
eslint: {
ignoreDuringBuilds: true,
turbo: {
treeShaking: true,
},
},
redirects: () =>
Object.entries({
'/api': '/docs',
Expand Down
4 changes: 3 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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 (
<Callout type="warning">
This is the documentation for the <b>old</b> GraphQL Mesh version v0. We recommend upgrading
to the latest GraphQL Mesh version v1.
<br />
<Link
href="/v1/migration-from-v0"
className="[*:has(div>&)]:mb-8 gap-2 underline hover:no-underline"
>
Migrate to GraphQL Mesh v1
</Link>
</Callout>
);
}
42 changes: 42 additions & 0 deletions website/src/app/(content-pages)/docs/[[...mdxPath]]/page.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<Wrapper toc={toc} metadata={metadata}>
<LegacyDocsBanner />
<MDXContent params={params} />
<ConfiguredGiscus />
</Wrapper>
);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
---
title: Examples
description: Examples of Mesh usage
---
'use client';

import { useState } from 'react'

<LiveDemo />
import { useState } from 'react';

export function LiveDemo() {
const [exampleRepo, setExampleRepo] = useState('json-schema-example')
const [exampleRepo, setExampleRepo] = useState('json-schema-example');
return (
<div className="min-h-[calc(100vh-var(--nextra-navbar-height))] flex flex-col">
<div className="flex items-center justify-center gap-2 py-8">
Choose Live Example:
<select
value={exampleRepo}
onChange={e => {
setExampleRepo(e.target.value)
setExampleRepo(e.target.value);
}}
className="border rounded-md py-1.5"
>
Expand All @@ -40,7 +35,7 @@ export function LiveDemo() {
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
/>
</div>
)
);
}

export const EXAMPLES = {
Expand All @@ -51,36 +46,36 @@ export const EXAMPLES = {
Stripe: 'openapi-stripe',
StackExchange: 'openapi-stackexchange',
'WeatherBit on React App': 'openapi-react-weatherbit',
'NextJS with Apollo': 'nextjs-apollo-example'
'NextJS with Apollo': 'nextjs-apollo-example',
},
'JSON Schema': {
'Fake API': 'json-schema-example',
'Covid-19 Statistics': 'json-schema-covid',
'Subscriptions, Webhooks & Live Queries': 'json-schema-subscriptions'
'Subscriptions, Webhooks & Live Queries': 'json-schema-subscriptions',
},
OData: {
TripPin: 'odata-trippin',
'Microsoft Graph': 'odata-microsoft'
'Microsoft Graph': 'odata-microsoft',
},
SOAP: {
'Country Info': 'soap-country-info'
'Country Info': 'soap-country-info',
},
MySQL: {
Rfam: 'mysql-rfam'
Rfam: 'mysql-rfam',
},
SQLite: {
Chinook: 'sqlite-chinook'
Chinook: 'sqlite-chinook',
},
'Apollo Federation': {
'Apollo Federation Example': 'federation-example'
'Apollo Federation Example': 'federation-example',
},
'Apache Thrift': {
Calculator: 'thrift-calculator'
Calculator: 'thrift-calculator',
},
gRPC: {
'Movies Example': 'grpc-example'
'Movies Example': 'grpc-example',
},
Neo4J: {
'Movies Example': 'neo4j-example'
}
}
'Movies Example': 'neo4j-example',
},
};
10 changes: 10 additions & 0 deletions website/src/app/(content-pages)/examples/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { LiveDemo } from './live-demo';

export const metadata = {
title: 'Examples',
description: 'Examples of Mesh usage',
};

export default function ExamplesPage() {
return <LiveDemo />;
}
6 changes: 6 additions & 0 deletions website/src/app/(content-pages)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { HiveInnerLayout } from '../../components/hive-layout/hive-inner-layout';
import '@theguild/components/style.css';

export default function RootLayout({ children }: { children: React.ReactNode }) {
return <HiveInnerLayout isLanding={false}>{children}</HiveInnerLayout>;
}
40 changes: 40 additions & 0 deletions website/src/app/(content-pages)/v1/[[...mdxPath]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* 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';

/**
* 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 (
<Wrapper toc={toc} metadata={metadata}>
<MDXContent params={params} />
<ConfiguredGiscus />
</Wrapper>
);
}
6 changes: 6 additions & 0 deletions website/src/app/(landing-pages)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { HiveInnerLayout } from '../../components/hive-layout/hive-inner-layout';
import '@theguild/components/style.css';

export default function RootLayout({ children }: { children: React.ReactNode }) {
return <HiveInnerLayout isLanding>{children}</HiveInnerLayout>;
}
6 changes: 6 additions & 0 deletions website/src/app/(landing-pages)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const metadata = {
title: 'GraphQL Mesh',
description: 'A fully-featured GraphQL gateway framework',
};

export { IndexPage as default } from '../../components/index-page';
8 changes: 0 additions & 8 deletions website/src/app/_app.tsx

This file was deleted.

75 changes: 41 additions & 34 deletions website/src/app/_meta.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
import Link from 'next/link';
import { Callout } from '@theguild/components';
// import { PRODUCTS_MENU_LIST } from '@theguild/components/products';

function LegacyDocsBanner() {
return (
<Callout type="warning">
This is the documentation for the <b>old</b> GraphQL Mesh version v0. We recommend upgrading
to the latest GraphQL Mesh version v1.
<br />
<br />
<Link
href={`/v1/migration-from-v0`}
className="_text-primary-600 _underline _decoration-from-font [text-underline-position:from-font]"
>
Migrate to GraphQL Mesh v1
</Link>
</Callout>
);
}

export default {
index: {
title: 'Home',
type: 'page',
display: 'hidden',
theme: {
layout: 'raw',
},
},
const meta = {
examples: {
title: 'Examples',
type: 'page',
display: 'hidden',
theme: {
layout: 'raw',
footer: false,
},
},
v1: {
title: 'v1',
Expand All @@ -43,8 +13,45 @@ export default {
docs: {
title: 'v0',
type: 'page',
theme: {
topContent: LegacyDocsBanner,
},
// #region shared items between all websites
// TODO: Move it to shared layout.
// products: PRODUCTS_MENU_LIST,
ecosystem: {
title: 'Ecosystem',
type: 'page',
href: 'https://the-guild.dev/graphql/hive/ecosystem',
},
blog: {
title: 'Blog',
type: 'page',
href: 'https://the-guild.dev/blog',
},
github: {
title: 'GitHub',
type: 'page',
href: 'https://github.com/ardatan/graphql-mesh',
},
'the-guild': {
title: 'The Guild',
type: 'menu',
items: {
'about-us': {
title: 'About Us',
href: 'https://the-guild.dev/about-us',
},
'brand-assets': {
title: 'Brand Assets',
href: 'https://the-guild.dev/logos',
},
},
},
'graphql-foundation': {
title: 'GraphQL Foundation',
type: 'page',
href: 'https://graphql.org/community/foundation/',
},
// #endregion
};

export default meta;
6 changes: 0 additions & 6 deletions website/src/app/index.mdx

This file was deleted.

Loading
Loading