diff --git a/src/components/Seo.jsx b/src/components/Seo.jsx index 40356978..251fc775 100644 --- a/src/components/Seo.jsx +++ b/src/components/Seo.jsx @@ -17,10 +17,65 @@ const query = graphql` } } } + + logo: allFile(filter: { name: { eq: "favicon-black" } }) { + edges { + node { + relativePath + } + } + } } ` -const MetaTags = ({ title, description, url, image, schema, siteMeta }) => ( +const createSchemaOrg = (title, description, image, url, siteMeta, article) => { + const schemaOrgJSONLD = [ + { + '@context': 'http://schema.org', + '@type': 'WebSite', + url: siteMeta.siteUrl, + name: title + } + ] + + if (article) { + schemaOrgJSONLD.push( + { + '@context': 'http://schema.org', + '@type': 'BreadcrumbList', + itemListElement: [ + { + '@type': 'ListItem', + position: 1, + item: { '@id': url, name: title, image } + } + ] + }, + { + // https://schema.org/TechArticle + '@context': 'http://schema.org', + '@type': 'TechArticle', + name: title, + headline: title, + description, + url, + image: { '@type': 'URL', url: image } + } + ) + } + + return schemaOrgJSONLD +} + +const MetaTags = ({ + title, + description, + url, + image, + schema, + siteMeta, + article +}) => ( ( {/* OpenGraph tags */} - {documentSEO && } + {article && } {/* Twitter Card tags */} - + @@ -59,27 +111,46 @@ const MetaTags = ({ title, description, url, image, schema, siteMeta }) => ( ) MetaTags.propTypes = { - description: PropTypes.string, - image: PropTypes.string, - url: PropTypes.string, - schema: PropTypes.string, title: PropTypes.string, - siteMeta: PropTypes.object + description: PropTypes.string, + url: PropTypes.string, + image: PropTypes.string, + schema: PropTypes.string, + siteMeta: PropTypes.object, + article: PropTypes.bool } -const SEO = ({ title, description, slug }) => ( +const SEO = ({ title, description, slug, article }) => ( { const siteMeta = data.site.siteMetadata + const logo = data.logo.edges[0].node.relativePath + + title = title || siteMeta.siteTitle + description = description || siteMeta.siteDescription + let url = siteMeta.siteUrl || siteMeta.siteUrl + slug + let image = `${siteMeta.siteUrl}/${logo}` + + let schema = createSchemaOrg( + title, + description, + image, + url, + siteMeta, + article + ) + schema = JSON.stringify(schema) return ( ) }} @@ -89,7 +160,8 @@ const SEO = ({ title, description, slug }) => ( SEO.propTypes = { title: PropTypes.string, description: PropTypes.string, - slug: PropTypes.string + slug: PropTypes.string, + article: PropTypes.bool } export default SEO diff --git a/src/pages/404.jsx b/src/pages/404.jsx index d6f3b96b..77c36fd8 100755 --- a/src/pages/404.jsx +++ b/src/pages/404.jsx @@ -6,7 +6,7 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import { Link } from 'gatsby' import giphyAPI from 'giphy-js-sdk-core' -import Helmet from 'react-helmet' +import SEO from '../components/Seo' import Layout from '../components/Layout' import Content from '../components/Content' import styles from './404.module.scss' @@ -45,7 +45,7 @@ export default class NotFoundPage extends Component { render() { return ( <> - +
diff --git a/src/templates/Doc.jsx b/src/templates/Doc.jsx index e4fcd4d7..cf8d6005 100644 --- a/src/templates/Doc.jsx +++ b/src/templates/Doc.jsx @@ -13,6 +13,25 @@ import DocFooter from '../components/DocFooter' import SEO from '../components/Seo' import styles from './Doc.module.scss' +const DocMain = ({ title, description, tableOfContents, post, single }) => ( +
+ + + {tableOfContents && } + + + +
+) + +DocMain.propTypes = { + title: PropTypes.string.isRequired, + description: PropTypes.string.isRequired, + tableOfContents: PropTypes.string.isRequired, + post: PropTypes.object.isRequired, + single: PropTypes.bool +} + export default class DocTemplate extends Component { static propTypes = { data: PropTypes.object.isRequired, @@ -41,7 +60,12 @@ export default class DocTemplate extends Component { - + @@ -55,42 +79,21 @@ export default class DocTemplate extends Component { sidebar={section} /> -
- - - {tableOfContents && ( - - )} - - - -
- - ) : ( -
- - - {tableOfContents && ( - - )} - - - -
+ + ) : ( + )}
@@ -112,6 +115,7 @@ export const pageQuery = graphql` } fields { section + slug } ...PageFooter } diff --git a/static/favicon.ico b/static/favicon.ico deleted file mode 100644 index 7db1da34..00000000 Binary files a/static/favicon.ico and /dev/null differ