Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 01e434f

Browse files
committed
move <NextSeo /> into <Layout />
1 parent 1ee9cf3 commit 01e434f

File tree

5 files changed

+69
-67
lines changed

5 files changed

+69
-67
lines changed

components/common/Layout.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import Meta from '@/components/common/Meta'
22
import Footer from '@/components/organisms/Footer'
33
import Header from '@/components/organisms/Header'
4+
import {NextSeo} from 'next-seo'
45
import PropTypes from 'prop-types'
56

6-
export default function Layout({children}) {
7+
export default function Layout({children, ...props}) {
78
return (
89
<>
10+
<NextSeo
11+
title={props?.title}
12+
description={props?.description}
13+
openGraph={props?.openGraph}
14+
nofollow={props?.noFollow}
15+
noindex={props?.noIndex}
16+
/>
917
<Meta />
1018
<Header />
1119
<main>{children}</main>
@@ -15,5 +23,10 @@ export default function Layout({children}) {
1523
}
1624

1725
Layout.propTypes = {
18-
children: PropTypes.any.isRequired
26+
children: PropTypes.any.isRequired,
27+
description: PropTypes.string.isRequired,
28+
noFollow: PropTypes.bool,
29+
noIndex: PropTypes.bool,
30+
openGraph: PropTypes.object,
31+
title: PropTypes.string.isRequired
1932
}

pages/[...slug].js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import getPostTypeStaticPaths from '@/api/wordpress/_global/getPostTypeStaticPaths'
22
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
33
import Layout from '@/components/common/Layout'
4-
import {NextSeo} from 'next-seo'
54
import PropTypes from 'prop-types'
65

76
// Define route post type.
@@ -16,21 +15,22 @@ const postType = 'page'
1615
*/
1716
export default function Page({post}) {
1817
return (
19-
<Layout>
20-
<NextSeo
21-
title="Query from Yoast SEO"
22-
description="Query from Yoast SEO"
23-
openGraph={{
24-
title: 'Query from Yoast SEO',
25-
description: 'Query from Yoast SEO',
26-
images: [
27-
{
28-
url: 'Query from Yoast SEO',
29-
alt: 'Query from Yoast SEO'
30-
}
31-
]
32-
}}
33-
/>
18+
<Layout
19+
title="Query from Yoast SEO"
20+
description="Query from Yoast SEO"
21+
noIndex={false} // query from yoast seo
22+
noFollow={false} // query from yoast seo
23+
openGraph={{
24+
title: 'Query from Yoast SEO',
25+
description: 'Query from Yoast SEO',
26+
images: [
27+
{
28+
url: 'Query from Yoast SEO',
29+
alt: 'Query from Yoast SEO'
30+
}
31+
]
32+
}}
33+
>
3434
<div className="container">
3535
<section>
3636
<article>

pages/_app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ export default function App({Component, pageProps}) {
2626
) : (
2727
<>
2828
<DefaultSeo
29-
title="Next.js WordPress Starter"
29+
title="Query from Yoast SEO"
3030
description="Query from Yoast SEO"
31+
noIndex={false} // query from yoast seo
32+
noFollow={false} // query from yoast seo
3133
openGraph={{
3234
type: 'website',
3335
locale: 'en_US',

pages/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import PropTypes from 'prop-types'
1+
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
22
import Layout from '@/components/common/Layout'
33
import Hero from '@/components/molecules/Hero'
4-
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
4+
import PropTypes from 'prop-types'
55
import Page from './[...slug]'
6-
import {NextSeo} from 'next-seo'
76

87
// Define route post type.
98
const postType = 'page'
@@ -23,21 +22,22 @@ export default function HomePage({post}) {
2322

2423
// Display static page content as fallback.
2524
return (
26-
<Layout>
27-
<NextSeo
28-
title="Query from Yoast SEO"
29-
description="Query from Yoast SEO"
30-
openGraph={{
31-
title: 'Query from Yoast SEO',
32-
description: 'Query from Yoast SEO',
33-
images: [
34-
{
35-
url: 'Query from Yoast SEO',
36-
alt: 'Query from Yoast SEO'
37-
}
38-
]
39-
}}
40-
/>
25+
<Layout
26+
title="Query from Yoast SEO"
27+
description="Query from Yoast SEO"
28+
noIndex={false} // query from yoast seo
29+
noFollow={false} // query from yoast seo
30+
openGraph={{
31+
title: 'Query from Yoast SEO',
32+
description: 'Query from Yoast SEO',
33+
images: [
34+
{
35+
url: 'Query from Yoast SEO',
36+
alt: 'Query from Yoast SEO'
37+
}
38+
]
39+
}}
40+
>
4141
<Hero
4242
background="https://images.unsplash.com/photo-1513106021000-168e5f56609d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2560&q=70"
4343
title="Next.js Starter"

pages/posts/[[...slug]].js

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import getPostTypeStaticPaths from '@/api/wordpress/_global/getPostTypeStaticPaths'
22
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
33
import Layout from '@/components/common/Layout'
4-
import {BlogJsonLd, NextSeo} from 'next-seo'
4+
import {BlogJsonLd} from 'next-seo'
55
import Link from 'next/link'
66
import PropTypes from 'prop-types'
77

@@ -28,20 +28,6 @@ export default function BlogPost({post, posts, archive}) {
2828
) : (
2929
posts.map((post, index) => (
3030
<>
31-
<NextSeo
32-
title="Query from Yoast SEO"
33-
description="Query from Yoast SEO"
34-
openGraph={{
35-
title: 'Query from Yoast SEO',
36-
description: 'Query from Yoast SEO',
37-
images: [
38-
{
39-
url: 'Query from Yoast SEO',
40-
alt: 'Query from Yoast SEO'
41-
}
42-
]
43-
}}
44-
/>
4531
<article key={index}>
4632
<Link href={post.uri}>
4733
<a>
@@ -61,21 +47,22 @@ export default function BlogPost({post, posts, archive}) {
6147
}
6248

6349
return (
64-
<Layout>
65-
<NextSeo
66-
title="Query from Yoast SEO"
67-
description="Query from Yoast SEO"
68-
openGraph={{
69-
title: 'Query from Yoast SEO',
70-
description: 'Query from Yoast SEO',
71-
images: [
72-
{
73-
url: 'Query from Yoast SEO',
74-
alt: 'Query from Yoast SEO'
75-
}
76-
]
77-
}}
78-
/>
50+
<Layout
51+
title="Query from Yoast SEO"
52+
description="Query from Yoast SEO"
53+
noIndex={false} // query from yoast seo
54+
noFollow={false} // query from yoast seo
55+
openGraph={{
56+
title: 'Query from Yoast SEO',
57+
description: 'Query from Yoast SEO',
58+
images: [
59+
{
60+
url: 'Query from Yoast SEO',
61+
alt: 'Query from Yoast SEO'
62+
}
63+
]
64+
}}
65+
>
7966
<BlogJsonLd
8067
url="Query from Yoast SEO"
8168
title="Query from Yoast SEO"

0 commit comments

Comments
 (0)