Skip to content

Commit 98ab501

Browse files
authored
Remove duplicate basePath (we have another one in metadataBase) (#6430)
1 parent 7484a41 commit 98ab501

File tree

7 files changed

+74
-9
lines changed

7 files changed

+74
-9
lines changed

packages/web/docs/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ export default withGuildDocs({
249249
],
250250
env: {
251251
SITE_URL: 'https://the-guild.dev/graphql/hive',
252+
NEXT_BASE_PATH: process.env.NEXT_BASE_PATH,
252253
},
253254
webpack: (config, { webpack }) => {
254255
config.externals['node:fs'] = 'commonjs node:fs';

packages/web/docs/src/app/docs/[[...mdxPath]]/page.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { generateStaticParamsFor, importPage } from 'nextra/pages';
44
import { NextPageProps } from '@theguild/components';
55
import { useMDXComponents } from '../../../../mdx-components.js';
66
import { ConfiguredGiscus } from '../../../components/configured-giscus';
7+
import { metadata as rootMetadata } from '../../layout';
78

89
export const generateStaticParams = generateStaticParamsFor('mdxPath');
910

@@ -13,12 +14,20 @@ export async function generateMetadata(
1314
) {
1415
const { mdxPath } = await props.params;
1516
const { metadata } = await importPage(mdxPath);
16-
return {
17+
const docsMetadata = {
1718
...metadata,
1819
...(mdxPath?.[0] === 'gateway' && {
1920
title: { absolute: `${metadata.title} | Hive Gateway` },
2021
}),
2122
};
23+
24+
// TODO: Remove this when Components have a fix for OG Images with basePath
25+
docsMetadata.openGraph = {
26+
...rootMetadata.openGraph,
27+
...docsMetadata.openGraph,
28+
};
29+
30+
return docsMetadata;
2231
}
2332

2433
const Wrapper = useMDXComponents().wrapper!;

packages/web/docs/src/app/federation/page.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FrequentlyAskedFederationQuestions } from '../../components/frequently-
66
import { Hero, HeroLinks } from '../../components/hero';
77
import { InfoCard } from '../../components/info-card';
88
import { LandingPageContainer } from '../../components/landing-page-container';
9+
import { metadata as rootMetadata } from '../layout';
910
import federationDiagram from '../../../public/federation-diagram.png';
1011
import queryResultImage from '../../../public/federation/query-result.png';
1112
import queryImage from '../../../public/federation/query.png';
@@ -17,6 +18,23 @@ export const metadata = {
1718
title: 'What is GraphQL Federation?',
1819
description:
1920
'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.',
21+
openGraph: {
22+
...rootMetadata.openGraph,
23+
/**
24+
* We currently have `metadataBase` which includes `basePath`,
25+
* so the opengraph-image.png file convention results in a
26+
* duplicate `basePath` in the OG Image URL.
27+
*
28+
* Remove this workaround when we have a fix upstream.
29+
* Do not extract this workaround to a separate file, as it will stop working.
30+
*/
31+
images: [
32+
new URL('./opengraph-image.png', import.meta.url)
33+
.toString()
34+
// eslint-disable-next-line no-process-env
35+
.replace(process.env.NEXT_BASE_PATH || '', ''),
36+
],
37+
},
2038
};
2139

2240
export default function FederationPage(): ReactElement {

packages/web/docs/src/app/layout.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ export const metadata = getDefaultMetadata({
2727
'Fully Open-source schema registry, analytics and gateway for GraphQL federation and other GraphQL APIs',
2828
});
2929

30+
metadata.openGraph = {
31+
...metadata.openGraph,
32+
// to remove leading slash
33+
url: '.',
34+
/**
35+
* We currently have `metadataBase` which includes `basePath`,
36+
* so the opengraph-image.png file convention results in a
37+
* duplicate `basePath` in the OG Image URL.
38+
*
39+
* Remove this workaround when we have a fix upstream.
40+
* Do not extract this workaround to a separate file, as it will stop working.
41+
*/
42+
images: [
43+
new URL('./opengraph-image.png', import.meta.url)
44+
.toString()
45+
// eslint-disable-next-line no-process-env
46+
.replace(process.env.NEXT_BASE_PATH || '', ''),
47+
],
48+
};
49+
3050
const neueMontreal = localFont({
3151
src: [
3252
{ path: '../fonts/PPNeueMontreal-Regular.woff2', weight: '400' },

packages/web/docs/src/app/page.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,7 @@ export const metadata: Metadata = {
3434
// to remove leading slash
3535
canonical: '.',
3636
},
37-
openGraph: {
38-
...rootMetadata.openGraph,
39-
// to remove leading slash
40-
url: '.',
41-
images: [new URL('./opengraph-image.png', import.meta.url).toString()],
42-
},
37+
openGraph: rootMetadata.openGraph,
4338
};
4439

4540
export default function IndexPage(): ReactElement {

packages/web/docs/src/app/partners/page.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,29 @@ import {
1111
import { FrequentlyAskedPartnersQuestions } from '../../components/frequently-asked-questions';
1212
import { Hero, HeroLinks } from '../../components/hero';
1313
import { LandingPageContainer } from '../../components/landing-page-container';
14+
import { metadata as rootMetadata } from '../layout';
1415

1516
export const metadata = {
1617
title: 'Partnerships',
1718
description:
1819
'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.',
20+
openGraph: {
21+
...rootMetadata.openGraph,
22+
/**
23+
* We currently have `metadataBase` which includes `basePath`,
24+
* so the opengraph-image.png file convention results in a
25+
* duplicate `basePath` in the OG Image URL.
26+
*
27+
* Remove this workaround when we have a fix upstream.
28+
* Do not extract this workaround to a separate file, as it will stop working.
29+
*/
30+
images: [
31+
new URL('./opengraph-image.png', import.meta.url)
32+
.toString()
33+
// eslint-disable-next-line no-process-env
34+
.replace(process.env.NEXT_BASE_PATH || '', ''),
35+
],
36+
},
1937
};
2038

2139
function WhyUs({ className }: { className?: string }) {

packages/web/docs/src/app/product-updates/(posts)/layout.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
'use client';
2-
31
import type { ReactElement, ReactNode } from 'react';
42
import { ConfiguredGiscus } from '../../../components/configured-giscus';
3+
import { metadata as rootMetadata } from '../../layout';
54
import { ProductUpdateHeader } from './product-update-header';
65

6+
export const metadata = {
7+
// TODO: Remove this when Components have a fix for OG Images with basePath
8+
openGraph: rootMetadata.openGraph,
9+
};
10+
711
const Layout = ({ children }: { children: ReactNode }): ReactElement => {
812
return (
913
<>

0 commit comments

Comments
 (0)