Skip to content

Commit

Permalink
feat: pass MDX frontmatter title into page <title>
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Jul 31, 2019
1 parent 292b43b commit 35a4536
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions packages/gatsby-theme-carbon/src/components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import Container from './Container';

import '../styles/index.scss';

const Layout = ({ children, homepage, shouldHideHeader, ...rest }) => {
const Layout = ({
children,
homepage,
shouldHideHeader,
pageTitle,
...rest
}) => {
const is404 = children.key === null;

useLayoutEffect(() => {
Expand All @@ -27,7 +33,7 @@ const Layout = ({ children, homepage, shouldHideHeader, ...rest }) => {

return (
<>
<Meta />
<Meta title={pageTitle} />
<Header shouldHideHeader={shouldHideHeader} />
<Switcher />
<LeftNav
Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-theme-carbon/src/components/Meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react';
import { Helmet } from 'react-helmet';
import { useMetadata } from '../util/hooks';

const Meta = () => {
const Meta = ({ title: pageTitle }) => {
const { title, description, keywords } = useMetadata();
return (
<Helmet
title={title}
title={pageTitle ? `${title} - ${pageTitle}` : title}
meta={[
{
name: 'description',
Expand Down
6 changes: 5 additions & 1 deletion packages/gatsby-theme-carbon/src/templates/Default.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ const Default = ({ pageContext, children, location }) => {

const currentTab = getCurrentTab();
return (
<Layout shouldHideHeader={shouldHideHeader} homepage={false}>
<Layout
shouldHideHeader={shouldHideHeader}
homepage={false}
pageTitle={title}
>
<PageHeader
shouldHideHeader={shouldHideHeader}
title={title}
Expand Down

0 comments on commit 35a4536

Please sign in to comment.