Just use frontmatter paths for paths + cleanups

This commit is contained in:
Kyle Mathews 2017-07-04 10:49:13 -07:00
parent 4936e80940
commit d2e2bc8df7
6 changed files with 33 additions and 63 deletions

View file

@ -13,7 +13,7 @@ if (process.env.NODE_ENV === `production`) {
}
}
module.exports = React.createClass({
export default class HTML extends React.Component {
render() {
const head = Helmet.rewind()
let css
@ -38,9 +38,6 @@ module.exports = React.createClass({
{this.props.headComponents}
<TypographyStyle typography={typography} />
{css}
{head.title.toComponent()}
{head.meta.toComponent()}
{head.link.toComponent()}
</head>
<body>
<div
@ -51,5 +48,5 @@ module.exports = React.createClass({
</body>
</html>
)
},
})
}
}

View file

@ -2,7 +2,6 @@ import React from "react"
import Link from "gatsby-link"
import get from "lodash/get"
import Helmet from "react-helmet"
import include from "underscore.string/include"
import Bio from "../components/Bio"
import { rhythm } from "../utils/typography"
@ -23,7 +22,7 @@ class BlogIndex extends React.Component {
marginBottom: rhythm(1 / 4),
}}
>
<Link style={{ boxShadow: "none" }} to={post.node.fields.slug}>
<Link style={{ boxShadow: "none" }} to={post.node.frontmatter.path}>
{post.node.frontmatter.title}
</Link>
</li>
@ -50,23 +49,23 @@ BlogIndex.propTypes = {
export default BlogIndex
export const pageQuery = graphql`
query IndexQuery {
site {
siteMetadata {
title
query IndexQuery {
site {
siteMetadata {
title
}
}
}
allMarkdownRemark {
edges {
node {
fields {
slug
}
frontmatter {
title
allMarkdownRemark {
edges {
node {
frontmatter {
path
}
frontmatter {
title
}
}
}
}
}
}
`

View file

@ -14,7 +14,9 @@ class BlogPostTemplate extends React.Component {
return (
<div>
<Helmet title={`${post.frontmatter.title} | ${siteTitle}`} />
<h1>{post.frontmatter.title}</h1>
<h1>
{post.frontmatter.title}
</h1>
<p
style={{
...scale(-1 / 5),
@ -40,14 +42,14 @@ class BlogPostTemplate extends React.Component {
export default BlogPostTemplate
export const pageQuery = graphql`
query BlogPostByPath($slug: String!) {
query BlogPostByPath($path: String!) {
site {
siteMetadata {
title
author
}
}
markdownRemark(fields: { slug: { eq: $slug }}) {
markdownRemark(frontmatter: { path: { eq: $path } }) {
id
html
frontmatter {