Skip to content

Commit 6142d5d

Browse files
committed
move Layout to use by wrapPageElement
1 parent b3fe458 commit 6142d5d

File tree

6 files changed

+39
-12
lines changed

6 files changed

+39
-12
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ gatsby-node.js
33
tailwind.config.js
44
postcss.config.js
55
gatsby-browser.js
6+
gatsby-ssr.js

gatsby-browser.js

+11
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,14 @@ import "fontsource-roboto-mono"
55

66
// custom CSS styles
77
import "./src/styles/style.css"
8+
9+
import * as React from 'react'
10+
import Layout from 'src/components/Layout'
11+
12+
const wrapPageElement = ({ element }) => {
13+
return (
14+
<Layout>{element}</Layout>
15+
)
16+
}
17+
18+
export { wrapPageElement }

gatsby-ssr.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
3+
*
4+
* See: https://www.gatsbyjs.org/docs/ssr-apis/
5+
*/
6+
7+
// You can delete this file if you're not using it
8+
import * as React from 'react'
9+
// import { Provider } from '~/store/global'
10+
import Layout from 'src/components/Layout'
11+
12+
const wrapPageElement = ({ element }) => {
13+
return (
14+
<Layout>{element}</Layout>
15+
)
16+
}
17+
18+
export { wrapPageElement }

src/pages/404.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import React from 'react'
22
import { PageProps } from 'gatsby'
33

4-
import Layout from 'src/components/Layout'
54
import { GatsbySeo } from 'gatsby-plugin-next-seo'
65

76
const NotFoundPage: React.FC<PageProps> = ({}) => {
87
return (
9-
<Layout>
8+
<>
109
<GatsbySeo title="404: Not Found" />
1110
<h1>404: Not Found</h1>
1211
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
13-
</Layout>
12+
</>
1413
)
1514
}
1615

src/pages/index.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { graphql, PageProps, Link } from 'gatsby'
33

44
import Bio from 'src/components/bio'
55
import { GatsbySeo } from 'gatsby-plugin-next-seo'
6-
import Layout from 'src/components/Layout'
76

87
const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
98
data,
@@ -12,20 +11,20 @@ const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
1211

1312
if (posts.length === 0) {
1413
return (
15-
<Layout>
14+
<>
1615
<GatsbySeo title="All posts" />
1716
<Bio />
1817
<p>
1918
No blog posts found. Add markdown posts to "content/blog" (or the
2019
directory you specified for the "gatsby-source-filesystem" plugin in
2120
gatsby-config.js).
2221
</p>
23-
</Layout>
22+
</>
2423
)
2524
}
2625

2726
return (
28-
<Layout>
27+
<>
2928
<GatsbySeo title="弱いZINE" titleTemplate="%s" />
3029
<ol style={{ listStyle: 'none' }}>
3130
{posts.map(post => {
@@ -67,7 +66,7 @@ const BlogIndex: React.FC<PageProps<GatsbyTypes.IndexPageQuery>> = ({
6766
)
6867
})}
6968
</ol>
70-
</Layout>
69+
</>
7170
)
7271
}
7372

@@ -77,7 +76,7 @@ export const pageQuery = graphql`
7776
query IndexPage {
7877
allMarkdownRemark(sort: { fields: [frontmatter___date], order: DESC }) {
7978
nodes {
80-
excerpt
79+
excerpt(truncate: true)
8180
fields {
8281
slug
8382
}

src/templates/blog-post.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react'
22
import { graphql, PageProps, Link } from 'gatsby'
33

44
import useTategaki from 'src/hooks/useTategaki'
5-
import Layout from 'src/components/Layout'
65
import { GatsbySeo } from 'gatsby-plugin-next-seo'
76

87
const BlogPostTemplate: React.FC<PageProps<
@@ -14,7 +13,7 @@ const BlogPostTemplate: React.FC<PageProps<
1413
const { tategakiRef } = useTategaki()
1514

1615
return (
17-
<Layout>
16+
<>
1817
<GatsbySeo
1918
title={post?.frontmatter?.title || ``}
2019
description={post?.frontmatter?.description || post?.excerpt || ``}
@@ -79,7 +78,7 @@ const BlogPostTemplate: React.FC<PageProps<
7978
</li>
8079
</ul>
8180
</nav>
82-
</Layout>
81+
</>
8382
)
8483
}
8584

0 commit comments

Comments
 (0)