Skip to content

Commit 953ac92

Browse files
authored
Merge pull request #3 from CodeDead/feature/seo
feature/seo
2 parents 3121979 + 560851b commit 953ac92

File tree

14 files changed

+117
-11
lines changed

14 files changed

+117
-11
lines changed

gatsby-config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ module.exports = {
4646
],
4747
},
4848
},
49+
{
50+
resolve: 'gatsby-plugin-google-gtag',
51+
options: {
52+
trackingIds: [
53+
'G-5BW4G4STJ8',
54+
],
55+
pluginConfig: {
56+
head: true,
57+
respectDNT: true,
58+
},
59+
},
60+
},
61+
'gatsby-plugin-react-helmet',
4962
'gatsby-transformer-remark',
5063
'gatsby-theme-material-ui',
5164
'gatsby-transformer-sharp',

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@material-ui/icons": "^4.11.2",
1919
"gatsby": "^2.31.1",
2020
"gatsby-image": "^2.10.0",
21+
"gatsby-plugin-google-gtag": "^2.7.0",
2122
"gatsby-plugin-sharp": "^2.13.4",
2223
"gatsby-plugin-sitemap": "^2.11.0",
2324
"gatsby-remark-images": "^3.10.0",
@@ -26,7 +27,8 @@
2627
"gatsby-transformer-remark": "^2.15.0",
2728
"gatsby-transformer-sharp": "^2.11.0",
2829
"react": "^17.0.1",
29-
"react-dom": "^17.0.1"
30+
"react-dom": "^17.0.1",
31+
"react-helmet": "^6.1.0"
3032
},
3133
"devDependencies": {
3234
"eslint-config-airbnb": "^18.2.1",

src/components/PageHeader/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
33
import Container from '@material-ui/core/Container';
44
import Typography from '@material-ui/core/Typography';
55
import BackButton from '../BackButton';
6+
import SEO from '../SEO';
67

78
const useStyles = makeStyles((theme) => ({
89
heroContent: {
@@ -16,6 +17,7 @@ const PageHeader = ({ title, subTitle, backButton }) => {
1617

1718
return (
1819
<div className={classes.heroContent}>
20+
<SEO title={title} description={subTitle} />
1921
<Container maxWidth="sm">
2022
<Typography variant="h4" align="center" color="textPrimary" gutterBottom>
2123
{backButton

src/components/SEO/index.jsx

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React from 'react';
2+
import { Helmet } from 'react-helmet';
3+
import { useStaticQuery, graphql } from 'gatsby';
4+
5+
function SEO({
6+
description, lang, meta, title,
7+
}) {
8+
const { site } = useStaticQuery(
9+
graphql`
10+
query {
11+
site {
12+
siteMetadata {
13+
title
14+
description
15+
author
16+
}
17+
}
18+
}
19+
`,
20+
);
21+
22+
const metaDescription = description || site.siteMetadata.description;
23+
const defaultTitle = site.siteMetadata.title;
24+
25+
return (
26+
<Helmet
27+
htmlAttributes={{
28+
lang,
29+
}}
30+
title={title}
31+
titleTemplate={defaultTitle ? `%s | ${defaultTitle}` : null}
32+
meta={[
33+
{
34+
name: 'description',
35+
content: metaDescription,
36+
},
37+
{
38+
property: 'og:title',
39+
content: title,
40+
},
41+
{
42+
property: 'og:description',
43+
content: metaDescription,
44+
},
45+
{
46+
property: 'og:type',
47+
content: 'website',
48+
},
49+
{
50+
name: 'twitter:card',
51+
content: 'summary',
52+
},
53+
{
54+
name: 'twitter:creator',
55+
content: site.siteMetadata.author || '',
56+
},
57+
{
58+
name: 'twitter:title',
59+
content: title,
60+
},
61+
{
62+
name: 'twitter:description',
63+
content: metaDescription,
64+
},
65+
].concat(meta)}
66+
/>
67+
);
68+
}
69+
70+
SEO.defaultProps = {
71+
lang: 'en',
72+
meta: [],
73+
description: '',
74+
};
75+
76+
export default SEO;

src/pages/404/index.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useContext, useEffect } from 'react';
22
import Container from '@material-ui/core/Container';
33
import Typography from '@material-ui/core/Typography';
44
import Card from '@material-ui/core/Card';
5-
import CardActionArea from '@material-ui/core/CardActionArea';
65
import CardContent from '@material-ui/core/CardContent';
76
import CardActions from '@material-ui/core/CardActions';
87
import Button from '@material-ui/core/Button';
@@ -32,7 +31,7 @@ const NotFoundPage = () => {
3231
</Typography>
3332
</CardContent>
3433
<CardActions>
35-
<Button color="primary" variant="outlined" href="/">
34+
<Button color="primary" variant="contained" href="/">
3635
Home
3736
</Button>
3837
</CardActions>

src/pages/software/advanced-passgen/requirements/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Requirements = () => {
2727

2828
return (
2929
<Layout>
30-
<PageHeader title="Advanced PassGen" subTitle="System requirements" backButton />
30+
<PageHeader title="Advanced PassGen - Requirements" subTitle="System requirements" backButton />
3131
<Container maxWidth="md" style={{ marginTop: 10 }}>
3232
<Grid container spacing={2} style={{ marginTop: 10 }}>
3333
<Grid item xs={12} md={12} lg={12}>

src/pages/software/advanced-portchecker/requirements/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Requirements = () => {
2727

2828
return (
2929
<Layout>
30-
<PageHeader title="Advanced PortChecker" subTitle="System requirements" backButton />
30+
<PageHeader title="Advanced PortChecker - Requirements" subTitle="System requirements" backButton />
3131
<Container maxWidth="md" style={{ marginTop: 10 }}>
3232
<Grid container spacing={2} style={{ marginTop: 10 }}>
3333
<Grid item xs={12} md={12} lg={12}>

src/pages/software/aniview/requirements/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Requirements = () => {
2727

2828
return (
2929
<Layout>
30-
<PageHeader title="AniView" subTitle="System requirements" backButton />
30+
<PageHeader title="AniView - Requirements" subTitle="System requirements" backButton />
3131
<Container maxWidth="md" style={{ marginTop: 10 }}>
3232
<Grid container spacing={2} style={{ marginTop: 10 }}>
3333
<Grid item xs={12} md={12} lg={12}>

src/pages/software/deadhash/requirements/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const Requirements = () => {
2626

2727
return (
2828
<Layout>
29-
<PageHeader title="DeadHash" subTitle="System requirements" backButton />
29+
<PageHeader title="DeadHash - Requirements" subTitle="System requirements" backButton />
3030
<Container maxWidth="md" style={{ marginTop: 10 }}>
3131
<Grid container spacing={2} style={{ marginTop: 10 }}>
3232
<Grid item xs={12} md={12} lg={12}>

src/pages/software/deadlock/requirements/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const Requirements = () => {
2727

2828
return (
2929
<Layout>
30-
<PageHeader title="DeadLock" subTitle="System requirements" backButton />
30+
<PageHeader title="DeadLock - Requirements" subTitle="System requirements" backButton />
3131
<Container maxWidth="md" style={{ marginTop: 10 }}>
3232
<Grid container spacing={2} style={{ marginTop: 10 }}>
3333
<Grid item xs={12} md={12} lg={12}>

0 commit comments

Comments
 (0)