Skip to content

Commit

Permalink
feat: automatically supply meta-data to head (carbon-design-system#133)
Browse files Browse the repository at this point in the history
feat: automatically supply meta-data to head
  • Loading branch information
vpicone authored May 31, 2019
2 parents 06069c3 + b50e7cf commit 052f8c5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/example/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
siteMetadata: {
title: 'Gatsby Theme Carbon',
description: 'A Gatsby theme for the carbon design system',
keywords: 'gatsby,theme,carbon',
},
plugins: [
{
Expand Down
3 changes: 3 additions & 0 deletions packages/gatsby-theme-carbon/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = themeOptions => {
siteMetadata: {
isSearchEnabled,
title: 'Gatsby Theme Carbon',
description:
'Add a description by supplying it to siteMetadata in your gatsby-config.js file.',
keywords: 'gatsby,theme,carbon,design',
},
pathPrefix: `/gatsby-theme-carbon`,
plugins: [
Expand Down
10 changes: 4 additions & 6 deletions packages/gatsby-theme-carbon/src/components/Meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@ import { Helmet } from 'react-helmet';
import { useMetadata } from '../util/hooks';

const Meta = () => {
const siteMetadata = useMetadata();
const { title, description, keywords } = useMetadata();
return (
<Helmet
title={siteMetadata.title}
title={title}
meta={[
{
name: 'description',
content:
'Carbon is the design system for IBM web and product. It is a series of individual styles, components, and guidelines used for creating unified UI.',
content: description,
},
{
name: 'keywords',
content:
'IBM, design, system, Carbon, design system, Bluemix, styleguide, style, guide, components, library, pattern, kit, component, cloud',
content: keywords,
},
]}
/>
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-theme-carbon/src/util/hooks/useMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const useMetadata = () => {
site {
siteMetadata {
title
description
keywords
isSearchEnabled
}
}
Expand Down

0 comments on commit 052f8c5

Please sign in to comment.