Skip to content

Commit 4ab72ea

Browse files
committed
Read site metadata from gatsby-config gile
1 parent 30dcb60 commit 4ab72ea

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

uilib-docs/gatsby-config.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ const {manifestPlugin, markdownPagesPlugin, componentsDocgenPlugin, incubatorCom
33
module.exports = {
44
pathPrefix: '/react-native-ui-lib',
55
siteMetadata: {
6-
title: `U I L I B`,
7-
description: `Kick off your next, great Gatsby project with this default starter. This barebones starter ships with the main Gatsby configuration files you might need.`,
8-
author: `@gatsbyjs`
6+
title: `RNUILib`,
7+
description: `React Native UI Toolset and Components Library`,
8+
author: `[email protected]`,
9+
domain: 'react-native-ui-lib'
910
},
1011
plugins: [
1112
`gatsby-plugin-react-helmet`,

uilib-docs/src/components/layout.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,34 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import Helmet from 'react-helmet';
44
import _ from 'lodash';
5+
import {graphql, useStaticQuery} from 'gatsby';
56

67
import Header from './header';
78
import Navbar from '../components/navbar';
89
import './layout.scss';
910

10-
const pathPrefix = '/react-native-ui-lib';
11-
1211
const Layout = ({children, location}) => {
12+
const data = useStaticQuery(
13+
graphql`
14+
query {
15+
site {
16+
siteMetadata {
17+
title
18+
description
19+
domain
20+
}
21+
}
22+
}
23+
`);
24+
1325
const {pathname} = location;
26+
const {site: {siteMetadata}} = data;
27+
28+
const metaTitle = siteMetadata.title;
29+
const metaDescription = siteMetadata.description;
30+
const pathPrefix = `/${siteMetadata.domain}`;
31+
1432
const showSidebar = _.replace(pathname, pathPrefix, '') !== '/';
15-
16-
const metaTitle = 'RNUILib';
17-
const metaDescription = 'React Native UI Toolset and Components Library';
18-
1933
return (
2034
<div className="layout">
2135
<Helmet>

0 commit comments

Comments
 (0)