Skip to content

Commit 9e1f70b

Browse files
Add scroll throttling, 404, and SEO
1 parent f1faf84 commit 9e1f70b

File tree

10 files changed

+4088
-1143
lines changed

10 files changed

+4088
-1143
lines changed

web/components/NavMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect } from 'react'
1+
import React from 'react'
22
import styled from 'styled-components'
33

44
const NavMenuPanel = styled.nav`

web/components/SEO.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from "react"
2+
import PropTypes from "prop-types"
3+
import { Helmet } from "react-helmet"
4+
// import { useLocation } from "@reach/router"
5+
import { useStaticQuery, graphql } from "gatsby"
6+
7+
const SEO = ({ title, description, image }) => {
8+
// const { pathname } = useLocation()
9+
const { site } = useStaticQuery(query)
10+
11+
const {
12+
defaultTitle,
13+
defaultDescription,
14+
siteUrl,
15+
defaultImage,
16+
} = site.siteMetadata
17+
18+
const seo = {
19+
title: title || defaultTitle,
20+
description: description || defaultDescription,
21+
// image: `${siteUrl}${image || defaultImage}`,
22+
// url: `${siteUrl}${pathname}`,
23+
}
24+
25+
return (
26+
<Helmet title={seo.title}>
27+
<meta name="description" content={seo.description} />
28+
<meta name="image" content={seo.image} />
29+
<meta name="author" content={seo.author} />
30+
31+
{seo.url && <meta property="og:url" content={seo.url} />}
32+
33+
{seo.title && <meta property="og:title" content={seo.title} />}
34+
35+
{seo.description && (
36+
<meta property="og:description" content={seo.description} />
37+
)}
38+
39+
{/* {seo.image && <meta property="og:image" content={seo.image} />} */}
40+
{/* {(article ? true : null) && <meta property="og:type" content="article" />} */}
41+
</Helmet>
42+
)
43+
}
44+
45+
export default SEO
46+
47+
SEO.propTypes = {
48+
title: PropTypes.string,
49+
description: PropTypes.string,
50+
image: PropTypes.string,
51+
article: PropTypes.bool,
52+
}
53+
54+
SEO.defaultProps = {
55+
title: null,
56+
description: null,
57+
image: null,
58+
article: false,
59+
}
60+
61+
const query = graphql`
62+
query SEO {
63+
site {
64+
siteMetadata {
65+
defaultTitle: title
66+
defaultDescription: description
67+
siteUrl: url
68+
}
69+
}
70+
}
71+
`

web/components/TopicSection.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import DescriptiveItem from './DescriptiveItem'
1010
// `
1111

1212
export default function TopicSection(props) {
13-
// console.log('TopicSection props: ', props)
1413
return (
1514
<section
1615
id={props.section.anchor_id}
17-
// key={props.section._id}
1816
>
1917
<div className='section_header'>
2018
<h3

web/components/layout.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,23 @@ const ListLink = props => (
77
</li>
88
)
99

10-
export default function Layout({ children }) {
11-
// TODO: is it problematic getting pathname from window? Better way to do it using Gatsby with React Router?
12-
const path = window.location.pathname
13-
console.log('path: ', path)
10+
export default function Layout(props) {
1411
return (
1512
<div id='layout'>
1613
<header>
1714
<h1>Web Dev Student Cheatsheet & Reference</h1>
1815

1916
<nav>
2017
<ul>
21-
{path === "/"
18+
{props.id !== "about"
2219
? <ListLink to='/about'>About</ListLink>
2320
: <ListLink to='/'>Home</ListLink>
2421
}
2522
</ul>
2623
</nav>
2724
</header>
2825

29-
<>{children}</>
26+
<>{props.children}</>
3027

3128
</div>
3229
)

web/gatsby-config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
/**
22
* Configure your Gatsby site with this file.
33
*
4-
* See: https://www.gatsbyjs.org/docs/gatsby-config/
4+
* See: https://www.gatsbyjs.org/docs/gatsby-config/`
55
*/
66

77
module.exports = {
8+
siteMetadata: {
9+
title: "Web Development Reference Guide",
10+
description: "A simple reference guide and cheatsheet on popular web development technologies with content aimed toward newer web developers.",
11+
author: "Jason Roundtree"
12+
// url: "https://www.reference.jasonroundtree.info",
13+
// image: "/images/", // Path to your image you placed in the 'static' folder
14+
},
815
plugins: [
16+
`gatsby-plugin-react-helmet`,
917
{
1018
resolve: 'gatsby-source-sanity',
1119
options: {

0 commit comments

Comments
 (0)