Make SEO score in Lighthouse = 100
For meta description used `excerpt` as it's close enough and doesn't require adding an extra frontmatter field.
This commit is contained in:
parent
ca3b074d29
commit
8a0da55d1c
2 changed files with 14 additions and 2 deletions
|
|
@ -10,11 +10,19 @@ import { rhythm } from '../utils/typography'
|
||||||
class BlogIndex extends React.Component {
|
class BlogIndex extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const siteTitle = get(this, 'props.data.site.siteMetadata.title')
|
const siteTitle = get(this, 'props.data.site.siteMetadata.title')
|
||||||
|
const siteDescription = get(
|
||||||
|
this,
|
||||||
|
'props.data.site.siteMetadata.description'
|
||||||
|
)
|
||||||
const posts = get(this, 'props.data.allMarkdownRemark.edges')
|
const posts = get(this, 'props.data.allMarkdownRemark.edges')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout location={this.props.location}>
|
<Layout location={this.props.location}>
|
||||||
<Helmet title={siteTitle} htmlAttributes={{ lang: 'en' }} />
|
<Helmet
|
||||||
|
htmlAttributes={{ lang: 'en' }}
|
||||||
|
meta={[{ name: 'description', content: siteDescription }]}
|
||||||
|
title={siteTitle}
|
||||||
|
/>
|
||||||
<Bio />
|
<Bio />
|
||||||
{posts.map(({ node }) => {
|
{posts.map(({ node }) => {
|
||||||
const title = get(node, 'frontmatter.title') || node.fields.slug
|
const title = get(node, 'frontmatter.title') || node.fields.slug
|
||||||
|
|
@ -46,6 +54,7 @@ export const pageQuery = graphql`
|
||||||
site {
|
site {
|
||||||
siteMetadata {
|
siteMetadata {
|
||||||
title
|
title
|
||||||
|
description
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
|
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,15 @@ class BlogPostTemplate extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const post = this.props.data.markdownRemark
|
const post = this.props.data.markdownRemark
|
||||||
const siteTitle = get(this.props, 'data.site.siteMetadata.title')
|
const siteTitle = get(this.props, 'data.site.siteMetadata.title')
|
||||||
|
const siteDescription = post.excerpt
|
||||||
const { previous, next } = this.props.pageContext
|
const { previous, next } = this.props.pageContext
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout location={this.props.location}>
|
<Layout location={this.props.location}>
|
||||||
<Helmet
|
<Helmet
|
||||||
title={`${post.frontmatter.title} | ${siteTitle}`}
|
|
||||||
htmlAttributes={{ lang: 'en' }}
|
htmlAttributes={{ lang: 'en' }}
|
||||||
|
meta={[{ name: 'description', content: siteDescription }]}
|
||||||
|
title={`${post.frontmatter.title} | ${siteTitle}`}
|
||||||
/>
|
/>
|
||||||
<h1>{post.frontmatter.title}</h1>
|
<h1>{post.frontmatter.title}</h1>
|
||||||
<p
|
<p
|
||||||
|
|
@ -80,6 +82,7 @@ export const pageQuery = graphql`
|
||||||
}
|
}
|
||||||
markdownRemark(fields: { slug: { eq: $slug } }) {
|
markdownRemark(fields: { slug: { eq: $slug } }) {
|
||||||
id
|
id
|
||||||
|
excerpt
|
||||||
html
|
html
|
||||||
frontmatter {
|
frontmatter {
|
||||||
title
|
title
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue