From 560851befc1e7d1dce9a32de700c2a305b5e5085 Mon Sep 17 00:00:00 2001 From: CodeDead Date: Tue, 2 Feb 2021 15:43:10 +0100 Subject: [PATCH] * Added SEO component * Added gtag --- gatsby-config.js | 13 ++++ package.json | 4 +- src/components/PageHeader/index.jsx | 2 + src/components/SEO/index.jsx | 76 +++++++++++++++++++ src/pages/404/index.jsx | 3 +- .../advanced-passgen/requirements/index.jsx | 2 +- .../requirements/index.jsx | 2 +- .../software/aniview/requirements/index.jsx | 2 +- .../software/deadhash/requirements/index.jsx | 2 +- .../software/deadlock/requirements/index.jsx | 2 +- .../software/deadpix/requirements/index.jsx | 2 +- .../software/memplus/requirements/index.jsx | 2 +- .../software/pk-finder/requirements/index.jsx | 2 +- yarn.lock | 14 ++++ 14 files changed, 117 insertions(+), 11 deletions(-) create mode 100644 src/components/SEO/index.jsx diff --git a/gatsby-config.js b/gatsby-config.js index d824669..14b5580 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -46,6 +46,19 @@ module.exports = { ], }, }, + { + resolve: 'gatsby-plugin-google-gtag', + options: { + trackingIds: [ + 'G-5BW4G4STJ8', + ], + pluginConfig: { + head: true, + respectDNT: true, + }, + }, + }, + 'gatsby-plugin-react-helmet', 'gatsby-transformer-remark', 'gatsby-theme-material-ui', 'gatsby-transformer-sharp', diff --git a/package.json b/package.json index 1c81662..bae5e63 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@material-ui/icons": "^4.11.2", "gatsby": "^2.31.1", "gatsby-image": "^2.10.0", + "gatsby-plugin-google-gtag": "^2.7.0", "gatsby-plugin-sharp": "^2.13.4", "gatsby-plugin-sitemap": "^2.11.0", "gatsby-remark-images": "^3.10.0", @@ -26,7 +27,8 @@ "gatsby-transformer-remark": "^2.15.0", "gatsby-transformer-sharp": "^2.11.0", "react": "^17.0.1", - "react-dom": "^17.0.1" + "react-dom": "^17.0.1", + "react-helmet": "^6.1.0" }, "devDependencies": { "eslint-config-airbnb": "^18.2.1", diff --git a/src/components/PageHeader/index.jsx b/src/components/PageHeader/index.jsx index 38eae39..42cfa43 100644 --- a/src/components/PageHeader/index.jsx +++ b/src/components/PageHeader/index.jsx @@ -3,6 +3,7 @@ import { makeStyles } from '@material-ui/core/styles'; import Container from '@material-ui/core/Container'; import Typography from '@material-ui/core/Typography'; import BackButton from '../BackButton'; +import SEO from '../SEO'; const useStyles = makeStyles((theme) => ({ heroContent: { @@ -16,6 +17,7 @@ const PageHeader = ({ title, subTitle, backButton }) => { return (
+ {backButton diff --git a/src/components/SEO/index.jsx b/src/components/SEO/index.jsx new file mode 100644 index 0000000..b2a163c --- /dev/null +++ b/src/components/SEO/index.jsx @@ -0,0 +1,76 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import { useStaticQuery, graphql } from 'gatsby'; + +function SEO({ + description, lang, meta, title, +}) { + const { site } = useStaticQuery( + graphql` + query { + site { + siteMetadata { + title + description + author + } + } + } + `, + ); + + const metaDescription = description || site.siteMetadata.description; + const defaultTitle = site.siteMetadata.title; + + return ( + + ); +} + +SEO.defaultProps = { + lang: 'en', + meta: [], + description: '', +}; + +export default SEO; diff --git a/src/pages/404/index.jsx b/src/pages/404/index.jsx index bc5815f..6a12dca 100644 --- a/src/pages/404/index.jsx +++ b/src/pages/404/index.jsx @@ -2,7 +2,6 @@ import React, { useContext, useEffect } from 'react'; import Container from '@material-ui/core/Container'; import Typography from '@material-ui/core/Typography'; import Card from '@material-ui/core/Card'; -import CardActionArea from '@material-ui/core/CardActionArea'; import CardContent from '@material-ui/core/CardContent'; import CardActions from '@material-ui/core/CardActions'; import Button from '@material-ui/core/Button'; @@ -32,7 +31,7 @@ const NotFoundPage = () => { - diff --git a/src/pages/software/advanced-passgen/requirements/index.jsx b/src/pages/software/advanced-passgen/requirements/index.jsx index 80a9353..878e8bc 100644 --- a/src/pages/software/advanced-passgen/requirements/index.jsx +++ b/src/pages/software/advanced-passgen/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/advanced-portchecker/requirements/index.jsx b/src/pages/software/advanced-portchecker/requirements/index.jsx index 493e8cb..71785d5 100644 --- a/src/pages/software/advanced-portchecker/requirements/index.jsx +++ b/src/pages/software/advanced-portchecker/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/aniview/requirements/index.jsx b/src/pages/software/aniview/requirements/index.jsx index b08d133..dafc2ac 100644 --- a/src/pages/software/aniview/requirements/index.jsx +++ b/src/pages/software/aniview/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/deadhash/requirements/index.jsx b/src/pages/software/deadhash/requirements/index.jsx index ce1203e..ceeb67a 100644 --- a/src/pages/software/deadhash/requirements/index.jsx +++ b/src/pages/software/deadhash/requirements/index.jsx @@ -26,7 +26,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/deadlock/requirements/index.jsx b/src/pages/software/deadlock/requirements/index.jsx index 5eb5b62..ccd8761 100644 --- a/src/pages/software/deadlock/requirements/index.jsx +++ b/src/pages/software/deadlock/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/deadpix/requirements/index.jsx b/src/pages/software/deadpix/requirements/index.jsx index 9f8378c..e957f5e 100644 --- a/src/pages/software/deadpix/requirements/index.jsx +++ b/src/pages/software/deadpix/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/memplus/requirements/index.jsx b/src/pages/software/memplus/requirements/index.jsx index 08b7035..71d287b 100644 --- a/src/pages/software/memplus/requirements/index.jsx +++ b/src/pages/software/memplus/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/src/pages/software/pk-finder/requirements/index.jsx b/src/pages/software/pk-finder/requirements/index.jsx index f660545..9c38fb1 100644 --- a/src/pages/software/pk-finder/requirements/index.jsx +++ b/src/pages/software/pk-finder/requirements/index.jsx @@ -27,7 +27,7 @@ const Requirements = () => { return ( - + diff --git a/yarn.lock b/yarn.lock index e90bf08..dc2d020 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4938,6 +4938,7 @@ __metadata: eslint-plugin-react-hooks: ^4.2.0 gatsby: ^2.31.1 gatsby-image: ^2.10.0 + gatsby-plugin-google-gtag: ^2.7.0 gatsby-plugin-sharp: ^2.13.4 gatsby-plugin-sitemap: ^2.11.0 gatsby-remark-images: ^3.10.0 @@ -4947,6 +4948,7 @@ __metadata: gatsby-transformer-sharp: ^2.11.0 react: ^17.0.1 react-dom: ^17.0.1 + react-helmet: ^6.1.0 languageName: unknown linkType: soft @@ -8287,6 +8289,18 @@ fsevents@~2.3.1: languageName: node linkType: hard +"gatsby-plugin-google-gtag@npm:^2.7.0": + version: 2.7.0 + resolution: "gatsby-plugin-google-gtag@npm:2.7.0" + dependencies: + "@babel/runtime": ^7.12.5 + minimatch: ^3.0.4 + peerDependencies: + gatsby: ^2.0.0 + checksum: 28e5ce35eacdfc5d31b42749b987e931ce7a22a58b065fd3d617fbc929ca9552a9dc4fa162f0198f29266c73a4a85694471a34d2376464675990bd3f2602ddbc + languageName: node + linkType: hard + "gatsby-plugin-material-ui@npm:^2.1.9": version: 2.1.10 resolution: "gatsby-plugin-material-ui@npm:2.1.10"