diff --git a/components/helmet/index.js b/components/helmet/index.js index bc27e8f5e..3cdcd2922 100644 --- a/components/helmet/index.js +++ b/components/helmet/index.js @@ -21,7 +21,7 @@ const Helmet = (props) => ( - + { props.canonical && } diff --git a/layouts/default/index.js b/layouts/default/index.js index aa293eb08..a4ae0bd02 100644 --- a/layouts/default/index.js +++ b/layouts/default/index.js @@ -1,5 +1,4 @@ import React from 'react'; -import Helmet from 'components/helmet'; import './global.scss'; import { firePageView } from 'lib/gtag'; diff --git a/lib/server.js b/lib/server.js index 4fa19c432..cd3fba233 100644 --- a/lib/server.js +++ b/lib/server.js @@ -5,6 +5,7 @@ */ export const serverOnlyProps = (callback) => { return async (props) => { + // noinspection JSUnresolvedVariable if (process.browser) { // noinspection ES6ModulesDependencies,JSUnresolvedVariable return __NEXT_DATA__.props.pageProps; diff --git a/pages/[roadmap]/index.js b/pages/[roadmap]/index.js index 776110fa1..924bfddf7 100644 --- a/pages/[roadmap]/index.js +++ b/pages/[roadmap]/index.js @@ -4,11 +4,12 @@ import SiteNav from 'components/site-nav'; import PageFooter from 'components/page-footer'; import { serverOnlyProps } from 'lib/server'; import { getRequestedRoadmap } from 'lib/roadmap'; +import siteConfig from 'storage/site'; import Helmet from 'components/helmet'; import RoadmapSummary from 'components/roadmap-summary'; import DetailedRoadmap from 'components/detailed-roadmap'; -const Roadmap = ({ roadmap }) => { +const Roadmap = ({ roadmap, canonical }) => { if (!roadmap) { return } @@ -16,7 +17,11 @@ const Roadmap = ({ roadmap }) => { const showSummary = roadmap.upcoming || !roadmap.detailed; return ( - + { showSummary ? : } @@ -26,6 +31,7 @@ const Roadmap = ({ roadmap }) => { Roadmap.getInitialProps = serverOnlyProps(({ req }) => { return { + canonical: `${siteConfig.url.web}${req.url}`, roadmap: getRequestedRoadmap(req), }; }); diff --git a/pages/guides/[guide].js b/pages/guides/[guide].js index 3fc667119..86f0befd5 100644 --- a/pages/guides/[guide].js +++ b/pages/guides/[guide].js @@ -6,15 +6,20 @@ import GuideBody from 'components/guide-body'; import GuideFooter from 'components/guide-footer'; import { getRequestedGuide } from 'lib/guide'; import Helmet from 'components/helmet'; +import siteConfig from 'storage/site'; -const Guide = ({ guide }) => { +const Guide = ({ guide, canonical }) => { if (!guide) { return } return ( - + @@ -24,6 +29,7 @@ const Guide = ({ guide }) => { Guide.getInitialProps = serverOnlyProps(async ({ req }) => { return { + canonical: `${siteConfig.url.web}${req.url}`, guide: await getRequestedGuide(req), }; });