Skip to content

Commit

Permalink
page head component (#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimiflynn authored Oct 23, 2024
1 parent eff8024 commit 8a8817d
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 93 deletions.
12 changes: 12 additions & 0 deletions site/src/components/page-head.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

function PageHead({ title, children }) {
return (
<>
<title>{title} | Morgan Stanley</title>
{children}
</>
);
}

export default PageHead;
71 changes: 0 additions & 71 deletions site/src/components/seo.js

This file was deleted.

6 changes: 5 additions & 1 deletion site/src/pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { graphql } from 'gatsby';

import Hero from '../components/hero';
import Layout from '../components/layout';
import PageHead from '../components/page-head';

const NotFoundPage = ({ data, location }) => {
return (
Expand All @@ -18,7 +19,10 @@ const NotFoundPage = ({ data, location }) => {

export default NotFoundPage;

export const Head = () => <title>404: Not Found</title>;
export const Head = ({ data }) => {
const title = `404: Not Found | ${data.site.siteMetadata.title}`;
return <PageHead title={title} />;
};

export const pageQuery = graphql`
query {
Expand Down
8 changes: 6 additions & 2 deletions site/src/pages/documentation/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { useCallback, useState } from 'react';
import { Link, graphql } from 'gatsby';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';

import PageHead from '../../components/page-head';
import Layout from '../../components/layout';
import VersionSelect from '../../components/version-select';
import { getDocsVersion } from '../../utils/version-docs';

import HeroContent from '../../../content/hero.mdx';
import { Toolbar } from '@mui/material';

const DocumentationIndex = ({ data, location }) => {
const allDocs = data.allMdx.nodes;
Expand Down Expand Up @@ -66,7 +67,10 @@ const DocumentationIndex = ({ data, location }) => {

export default DocumentationIndex;

export const Head = () => <title>Documentation</title>;
export const Head = ({ data }) => {
const title = `Documentation | ${data.site.siteMetadata.title}`;
return <PageHead title={title} />;
};

export const pageQuery = graphql`
query {
Expand Down
5 changes: 5 additions & 0 deletions site/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import HeroContent from '../../content/hero.mdx';
import UseCases from '../../content/use-cases.mdx';

import Article from '../components/article';
import PageHead from '../components/page-head';
import Layout from '../components/layout';

const SiteIndex = ({ data, location }) => {
Expand All @@ -34,6 +35,10 @@ const SiteIndex = ({ data, location }) => {
);
};

export const Head = ({ data }) => (
<PageHead title={data.site.siteMetadata.title} />
);

export default SiteIndex;

export const pageQuery = graphql`
Expand Down
5 changes: 4 additions & 1 deletion site/src/pages/news/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { Link, graphql } from 'gatsby';

import Layout from '../../components/layout';
import PageHead from '../../components/page-head';

import HeroContent from '../../../content/hero.mdx';

Expand Down Expand Up @@ -32,7 +33,9 @@ const NewsIndex = ({ data, location }) => {

export default NewsIndex;

export const Head = () => <title>News</title>;
export const Head = ({ data }) => (
<PageHead title={data.site.siteMetadata.title} />
);

export const pageQuery = graphql`
query {
Expand Down
15 changes: 9 additions & 6 deletions site/src/templates/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Link, navigate, graphql } from 'gatsby';
import { Box } from '@mui/material';

import Layout from '../components/layout';
import PageHead from '../components/page-head';
import VersionSelect from '../components/version-select';
import { getCurrentVersion, getDocsVersion } from '../utils/version-docs';

Expand Down Expand Up @@ -83,12 +84,14 @@ const DocumentationTemplate = ({ children, data, pageContext, location }) => {

export default DocumentationTemplate;

export const Head = ({ pageContext }) => (
<>
<title>{pageContext.frontmatter.title}</title>
<meta name="description" content={pageContext.description} />
</>
);
export const Head = ({ data, pageContext }) => {
const title = `${pageContext.frontmatter.title} | ${data.site.siteMetadata.title}`;
return (
<PageHead title={title}>
<meta name="description" content={pageContext.description} />
</PageHead>
);
};

export const pageQuery = graphql`
query ($id: String!) {
Expand Down
15 changes: 9 additions & 6 deletions site/src/templates/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { graphql } from 'gatsby';

import Layout from '../components/layout';
import PageHead from '../components/page-head';
import Section from '../components/section';

const NewsPostTemplate = ({ children, data, pageContext, location }) => {
Expand All @@ -24,12 +25,14 @@ const NewsPostTemplate = ({ children, data, pageContext, location }) => {

export default NewsPostTemplate;

export const Head = ({ pageContext }) => (
<>
<title>{pageContext.title}</title>
<meta name="description" content={pageContext.description} />
</>
);
export const Head = ({ data, pageContext }) => {
const title = `${pageContext.frontmatter.title} | ${data.site.siteMetadata.title}`;
return (
<PageHead title={title}>
<meta name="description" content={pageContext.description} />
</PageHead>
);
};

export const pageQuery = graphql`
query ($id: String!) {
Expand Down
15 changes: 9 additions & 6 deletions site/src/templates/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { graphql } from 'gatsby';

import Layout from '../components/layout';
import PageHead from '../components/page-head';

const PageTemplate = ({ title, data, location, children }) => {
return (
Expand All @@ -18,12 +19,14 @@ const PageTemplate = ({ title, data, location, children }) => {

export default PageTemplate;

export const Head = ({ pageContext }) => (
<>
<title>{pageContext.title}</title>
<meta name="description" content={pageContext.description} />
</>
);
export const Head = ({ data, pageContext }) => {
const title = `${pageContext.frontmatter.title} | ${data.site.siteMetadata.title}`;
return (
<PageHead title={title}>
<meta name="description" content={pageContext.description} />
</PageHead>
);
};

export const pageQuery = graphql`
query ($id: String!) {
Expand Down

0 comments on commit 8a8817d

Please sign in to comment.