Skip to content

Commit 2cc66f8

Browse files
committed
feat: enable head component and native typegen
1 parent 9b71a9f commit 2cc66f8

File tree

21 files changed

+2566
-1895
lines changed

21 files changed

+2566
-1895
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ yarn-error.log
7373
*.swp
7474

7575
# Codegen stuff
76-
src/__generated__/
76+
src/gatsby-types.d.ts

.prettierrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"arrowParens": "avoid",
3-
"semi": false
4-
}
3+
"semi": false,
4+
"singleQuote": false
5+
}

gatsby-config.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ module.exports = {
55
"A query language for your API — GraphQL provides a complete description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.",
66
siteUrl: "http://graphql.org/",
77
},
8-
8+
graphqlTypegen: true,
99
plugins: [
10-
"gatsby-plugin-react-helmet",
11-
'gatsby-plugin-anchor-links',
10+
"gatsby-plugin-anchor-links",
1211
{
1312
resolve: "gatsby-source-filesystem",
1413
options: {
@@ -23,11 +22,11 @@ module.exports = {
2322
{
2423
resolve: "@weknow/gatsby-remark-twitter",
2524
options: {
26-
debug: true
27-
}
28-
}
29-
]
30-
}
25+
debug: true,
26+
},
27+
},
28+
],
29+
},
3130
},
3231
{
3332
resolve: `gatsby-plugin-webfonts`,
@@ -51,7 +50,6 @@ module.exports = {
5150
},
5251
},
5352
`gatsby-plugin-less`,
54-
`gatsby-plugin-react-helmet`,
5553
{
5654
resolve: `gatsby-plugin-google-analytics`,
5755
options: {
@@ -115,11 +113,5 @@ module.exports = {
115113
],
116114
},
117115
},
118-
{
119-
resolve: "gatsby-plugin-typegen",
120-
options: {
121-
outputPath: "src/__generated__/gatsby-types.d.ts",
122-
},
123-
},
124116
],
125117
}

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
"assert": "2.0.0",
2222
"codemirror": "5.65.1",
2323
"codemirror-graphql": "1.2.11",
24-
"gatsby": "4.7.2",
24+
"gatsby": "4.24.8",
2525
"gatsby-plugin-anchor-links": "1.2.1",
2626
"gatsby-plugin-feed": "4.7.0",
2727
"gatsby-plugin-google-analytics": "4.7.0",
2828
"gatsby-plugin-less": "6.7.0",
29-
"gatsby-plugin-react-helmet": "5.7.0",
3029
"gatsby-plugin-typegen": "2.2.4",
3130
"gatsby-plugin-webfonts": "2.2.1",
3231
"gatsby-source-filesystem": "4.7.0",
@@ -40,13 +39,11 @@
4039
"prismjs": "1.25.0",
4140
"react": "17.0.2",
4241
"react-dom": "17.0.2",
43-
"react-helmet": "6.1.0",
4442
"timeago.js": "4.0.2"
4543
},
4644
"devDependencies": {
4745
"@types/codemirror": "5.60.5",
4846
"@types/prismjs": "1.16.6",
49-
"@types/react-helmet": "6.1.4",
5047
"prettier": "2.4.1"
5148
}
52-
}
49+
}

src/components/BlogLayout/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ export const fragments = graphql`
77
fragment BlogLayout_post on BlogPost {
88
...BlogPost_post
99
}
10-
`;
10+
`
1111

1212
interface Props {
13-
post: GatsbyTypes.BlogLayout_postFragment,
13+
post: Queries.BlogLayout_postFragment
1414
}
1515

16-
const BlogLayout: React.FC<Props> = ({
17-
post,
18-
}) => {
16+
const BlogLayout: React.FC<Props> = ({ post }) => {
1917
return (
2018
<section>
2119
<div className="documentationContent">

src/components/BlogPost/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ export const fragments = graphql`
1313
rawMarkdownBody
1414
}
1515
}
16-
`;
16+
`
1717

1818
interface Props {
19-
post: GatsbyTypes.BlogPost_postFragment,
19+
post: Queries.BlogPost_postFragment
2020
}
2121

22-
const BlogPost: React.FC<Props> = ({
23-
post,
24-
}) => {
25-
const byline = post.authors.join(', ')
22+
const BlogPost: React.FC<Props> = ({ post }) => {
23+
const byline = post.authors.join(", ")
2624
return (
2725
<div className="inner-content">
2826
<h1>{post.title}</h1>

src/components/BlogPostPreview/index.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@ export const fragments = graphql`
1212
excerpt
1313
}
1414
}
15-
`;
15+
`
1616

1717
interface Props {
18-
post: GatsbyTypes.BlogPostPreview_postFragment,
18+
post: Queries.BlogPostPreview_postFragment
1919
}
2020

21-
const BlogPostPreview: React.FC<Props> = ({
22-
post,
23-
}) => (
21+
const BlogPostPreview: React.FC<Props> = ({ post }) => (
2422
<div className="inner-content">
2523
<h1>
2624
<Link to={post.postPath!}>{post.title}</Link>
2725
</h1>
2826

2927
<p>
30-
{new Date(post.date).toLocaleDateString()} by {post.authors.join(', ')}
28+
{new Date(post.date).toLocaleDateString()} by {post.authors.join(", ")}
3129
</p>
3230

3331
<div className="tag-wrapper">

src/components/BlogSidebar/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import { Link, useStaticQuery, graphql } from "gatsby"
33
import { useLocation } from "@reach/router"
44

55
const BlogSidebar: React.FC = () => {
6-
const data = useStaticQuery<GatsbyTypes.AllTagsStaticQuery>(graphql`
6+
const data = useStaticQuery<Queries.AllTagsStaticQuery>(graphql`
77
query AllTagsStatic {
88
allBlogPost {
99
group(field: tags) {
1010
fieldValue
1111
}
1212
}
1313
allRecentBlogPost: allBlogPost(
14-
limit: 30,
14+
limit: 30
1515
sort: { fields: [date], order: DESC }
1616
) {
1717
nodes {
@@ -26,7 +26,7 @@ const BlogSidebar: React.FC = () => {
2626
const tags = data.allBlogPost.group.map(group => group.fieldValue!)
2727
const recentPosts = data.allRecentBlogPost.nodes
2828

29-
const { pathname: currentPath } = useLocation();
29+
const { pathname: currentPath } = useLocation()
3030

3131
return (
3232
<div className="nav-docs blog-sidebar">
@@ -41,7 +41,7 @@ const BlogSidebar: React.FC = () => {
4141
<ul>
4242
{tags.map(tag => {
4343
const formattedTag = tag[0].toUpperCase() + tag.substring(1)
44-
const pathname = `/tags/${tag}/`;
44+
const pathname = `/tags/${tag}/`
4545
return (
4646
<li key={tag}>
4747
{pathname === currentPath ? (

src/components/Layout/index.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
import React from "react"
22
import Footer from "../Footer"
33
import Header from "../Header"
4-
import Seo from "../Seo"
54

65
import "../../assets/css/style.less"
76

8-
interface PageContext {
9-
sourcePath?: string
10-
}
11-
127
interface Props {
138
children: React.ReactNode
14-
title?: string
15-
description?: string
169
className?: string
17-
pageContext: PageContext
10+
pageContext?: { sourcePath?: string }
1811
}
1912
const IndexLayout = ({
20-
title,
21-
description,
2213
children,
2314
className,
24-
pageContext: { sourcePath },
15+
pageContext: { sourcePath } = {},
2516
}: Props): JSX.Element => (
2617
<>
27-
<Seo title={title} description={description} />
2818
<div className={className}>
2919
<Header />
3020
{children}

src/components/Seo/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react"
2-
import Helmet from "react-helmet"
32
import { useStaticQuery, graphql } from "gatsby"
43

54
interface Props {
@@ -8,7 +7,7 @@ interface Props {
87
}
98

109
const Seo = ({ title, description }: Props): JSX.Element => {
11-
const data = useStaticQuery<GatsbyTypes.SeoQueryQuery>(graphql`
10+
const data = useStaticQuery<Queries.SeoQueryQuery>(graphql`
1211
query SeoQuery {
1312
site {
1413
siteMetadata {
@@ -19,16 +18,16 @@ const Seo = ({ title, description }: Props): JSX.Element => {
1918
}
2019
`)
2120

22-
const metadata = data.site.siteMetadata
21+
const metadata = data.site!.siteMetadata
2322

2423
return (
25-
<Helmet>
26-
<title>{title ?? metadata.title}</title>
27-
<meta name="description" content={description ?? metadata.description} />
24+
<>
25+
<title>{title ?? metadata!.title}</title>
26+
<meta name="description" content={description ?? metadata!.description} />
2827
<meta property="og:image" content="/img/og-image.png" />
2928
<meta property="twitter:site" content="@graphql" />
3029
<meta name="viewport" content="width=640" />
31-
</Helmet>
30+
</>
3231
)
3332
}
3433

0 commit comments

Comments
 (0)