Skip to content

Commit

Permalink
Remove duplicate basePath (we have another one in metadataBase) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus authored Jan 29, 2025
1 parent 7484a41 commit 98ab501
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/web/docs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export default withGuildDocs({
],
env: {
SITE_URL: 'https://the-guild.dev/graphql/hive',
NEXT_BASE_PATH: process.env.NEXT_BASE_PATH,
},
webpack: (config, { webpack }) => {
config.externals['node:fs'] = 'commonjs node:fs';
Expand Down
11 changes: 10 additions & 1 deletion packages/web/docs/src/app/docs/[[...mdxPath]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateStaticParamsFor, importPage } from 'nextra/pages';
import { NextPageProps } from '@theguild/components';
import { useMDXComponents } from '../../../../mdx-components.js';
import { ConfiguredGiscus } from '../../../components/configured-giscus';
import { metadata as rootMetadata } from '../../layout';

export const generateStaticParams = generateStaticParamsFor('mdxPath');

Expand All @@ -13,12 +14,20 @@ export async function generateMetadata(
) {
const { mdxPath } = await props.params;
const { metadata } = await importPage(mdxPath);
return {
const docsMetadata = {
...metadata,
...(mdxPath?.[0] === 'gateway' && {
title: { absolute: `${metadata.title} | Hive Gateway` },
}),
};

// TODO: Remove this when Components have a fix for OG Images with basePath
docsMetadata.openGraph = {
...rootMetadata.openGraph,
...docsMetadata.openGraph,
};

return docsMetadata;
}

const Wrapper = useMDXComponents().wrapper!;
Expand Down
18 changes: 18 additions & 0 deletions packages/web/docs/src/app/federation/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FrequentlyAskedFederationQuestions } from '../../components/frequently-
import { Hero, HeroLinks } from '../../components/hero';
import { InfoCard } from '../../components/info-card';
import { LandingPageContainer } from '../../components/landing-page-container';
import { metadata as rootMetadata } from '../layout';
import federationDiagram from '../../../public/federation-diagram.png';
import queryResultImage from '../../../public/federation/query-result.png';
import queryImage from '../../../public/federation/query.png';
Expand All @@ -17,6 +18,23 @@ export const metadata = {
title: 'What is GraphQL Federation?',
description:
'Discover what GraphQL Federation is, how it unifies multiple APIs into a Supergraph, its core benefits, and the building blocks like subgraphs, schema composition and gateway.',
openGraph: {
...rootMetadata.openGraph,
/**
* We currently have `metadataBase` which includes `basePath`,
* so the opengraph-image.png file convention results in a
* duplicate `basePath` in the OG Image URL.
*
* Remove this workaround when we have a fix upstream.
* Do not extract this workaround to a separate file, as it will stop working.
*/
images: [
new URL('./opengraph-image.png', import.meta.url)
.toString()
// eslint-disable-next-line no-process-env
.replace(process.env.NEXT_BASE_PATH || '', ''),
],
},
};

export default function FederationPage(): ReactElement {
Expand Down
20 changes: 20 additions & 0 deletions packages/web/docs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ export const metadata = getDefaultMetadata({
'Fully Open-source schema registry, analytics and gateway for GraphQL federation and other GraphQL APIs',
});

metadata.openGraph = {
...metadata.openGraph,
// to remove leading slash
url: '.',
/**
* We currently have `metadataBase` which includes `basePath`,
* so the opengraph-image.png file convention results in a
* duplicate `basePath` in the OG Image URL.
*
* Remove this workaround when we have a fix upstream.
* Do not extract this workaround to a separate file, as it will stop working.
*/
images: [
new URL('./opengraph-image.png', import.meta.url)
.toString()
// eslint-disable-next-line no-process-env
.replace(process.env.NEXT_BASE_PATH || '', ''),
],
};

const neueMontreal = localFont({
src: [
{ path: '../fonts/PPNeueMontreal-Regular.woff2', weight: '400' },
Expand Down
7 changes: 1 addition & 6 deletions packages/web/docs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ export const metadata: Metadata = {
// to remove leading slash
canonical: '.',
},
openGraph: {
...rootMetadata.openGraph,
// to remove leading slash
url: '.',
images: [new URL('./opengraph-image.png', import.meta.url).toString()],
},
openGraph: rootMetadata.openGraph,
};

export default function IndexPage(): ReactElement {
Expand Down
18 changes: 18 additions & 0 deletions packages/web/docs/src/app/partners/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@ import {
import { FrequentlyAskedPartnersQuestions } from '../../components/frequently-asked-questions';
import { Hero, HeroLinks } from '../../components/hero';
import { LandingPageContainer } from '../../components/landing-page-container';
import { metadata as rootMetadata } from '../layout';

export const metadata = {
title: 'Partnerships',
description:
'Accelerate GraphQL Federation adoption with the Hive Partner Network. Access enterprise-grade tools and expertise to build scalable, unified APIs across distributed systems. Join our network of federation experts.',
openGraph: {
...rootMetadata.openGraph,
/**
* We currently have `metadataBase` which includes `basePath`,
* so the opengraph-image.png file convention results in a
* duplicate `basePath` in the OG Image URL.
*
* Remove this workaround when we have a fix upstream.
* Do not extract this workaround to a separate file, as it will stop working.
*/
images: [
new URL('./opengraph-image.png', import.meta.url)
.toString()
// eslint-disable-next-line no-process-env
.replace(process.env.NEXT_BASE_PATH || '', ''),
],
},
};

function WhyUs({ className }: { className?: string }) {
Expand Down
8 changes: 6 additions & 2 deletions packages/web/docs/src/app/product-updates/(posts)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
'use client';

import type { ReactElement, ReactNode } from 'react';
import { ConfiguredGiscus } from '../../../components/configured-giscus';
import { metadata as rootMetadata } from '../../layout';
import { ProductUpdateHeader } from './product-update-header';

export const metadata = {
// TODO: Remove this when Components have a fix for OG Images with basePath
openGraph: rootMetadata.openGraph,
};

const Layout = ({ children }: { children: ReactNode }): ReactElement => {
return (
<>
Expand Down

0 comments on commit 98ab501

Please sign in to comment.