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

Commit d9cc26e

Browse files
committed
add <NextSeo /> component
1 parent 6a59fe5 commit d9cc26e

File tree

2 files changed

+55
-35
lines changed

2 files changed

+55
-35
lines changed

pages/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
import Layout from '@/components/common/Layout'
22
import Hero from '@/components/molecules/Hero'
3-
import config from '@/functions/config'
3+
import {NextSeo} from 'next-seo'
44

55
export default function HomePage() {
66
return (
7-
<Layout title={config.siteTitle} description={config.siteDescription}>
7+
<Layout>
8+
<NextSeo
9+
title="Query from Yoast SEO"
10+
description="Query from Yoast SEO"
11+
openGraph={{
12+
title: 'Query from Yoast SEO',
13+
description: 'Query from Yoast SEO',
14+
images: [
15+
{
16+
url: 'Query from Yoast SEO',
17+
alt: 'Query from Yoast SEO'
18+
}
19+
]
20+
}}
21+
/>
822
<Hero
923
background="https://images.unsplash.com/photo-1513106021000-168e5f56609d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2560&q=70"
1024
title="Next.js Starter"

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

Lines changed: 39 additions & 33 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 {Info} from '@/components/molecules/Alert'
54
import {BlogJsonLd, NextSeo} from 'next-seo'
65
import Link from 'next/link'
76
import PropTypes from 'prop-types'
@@ -21,37 +20,28 @@ export default function BlogPost({post, posts, archive}) {
2120
// TODO create generic archive component and move this check to `_app.js`.
2221
if (archive) {
2322
return (
24-
<Layout title="Blog">
25-
<NextSeo
26-
title="Query from Yoast SEO"
27-
description="Query from Yoast SEO"
28-
openGraph={{
29-
title: 'Query from Yoast SEO',
30-
description: 'Query from Yoast SEO',
31-
images: [
32-
{
33-
url: 'Query from Yoast SEO',
34-
alt: 'Query from Yoast SEO'
35-
}
36-
]
37-
}}
38-
/>
39-
<BlogJsonLd
40-
url="Query from Yoast SEO"
41-
title="Query from Yoast SEO"
42-
images={['Query from Yoast SEO']}
43-
datePublished="Query from Yoast SEO"
44-
dateModified="Query from Yoast SEO"
45-
authorName="Jane Blogs"
46-
description="Query from Yoast SEO"
47-
/>
23+
<Layout>
4824
<div className="container">
4925
<section>
5026
{!posts || !posts.length ? (
5127
<p>No posts found.</p>
5228
) : (
5329
posts.map((post, index) => (
5430
<>
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+
/>
5545
<article key={index}>
5646
<Link href={post.uri}>
5747
<a>
@@ -71,15 +61,31 @@ export default function BlogPost({post, posts, archive}) {
7161
}
7262

7363
return (
74-
<Layout title={post?.title} description={post?.excerpt}>
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+
/>
79+
<BlogJsonLd
80+
url="Query from Yoast SEO"
81+
title="Query from Yoast SEO"
82+
images={['Query from Yoast SEO']}
83+
datePublished="Query from Yoast SEO"
84+
dateModified="Query from Yoast SEO"
85+
authorName="Query from Yoast SEO"
86+
description="Query from Yoast SEO"
87+
/>
7588
<div className="container">
76-
<Info>
77-
The content below is sourced from the WordPress REST-API.{' '}
78-
<a href="https://nextjs.org/docs/basic-features/data-fetching#getstaticpaths-static-generation">
79-
Learn more about SSG.
80-
</a>
81-
</Info>
82-
8389
<section>
8490
<article>
8591
<h1 dangerouslySetInnerHTML={{__html: post?.title}} />

0 commit comments

Comments
 (0)