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

Commit 48b0ce6

Browse files
authored
Merge pull request #56 from WebDevStudios/feature/#55-seo
Feature/#55 seo
2 parents 21c4311 + c209f2c commit 48b0ce6

File tree

13 files changed

+114
-284
lines changed

13 files changed

+114
-284
lines changed

components/common/Layout.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
1+
import Meta from '@/components/common/Meta'
2+
import Footer from '@/components/organisms/Footer'
3+
import Header from '@/components/organisms/Header'
14
import PropTypes from 'prop-types'
2-
import Meta from './Meta'
3-
import Header from '../organisms/Header'
4-
import Footer from '../organisms/Footer'
5-
import config from '@/functions/config'
65

7-
export default function Layout({children, ...props}) {
6+
export default function Layout({children}) {
87
return (
98
<>
10-
<Meta title={props.title} description={props.description} />
9+
<Meta />
1110
<Header />
1211
<main>{children}</main>
1312
<Footer />
1413
</>
1514
)
1615
}
1716

18-
Layout.defaultProps = {
19-
description: config.siteDescription,
20-
title: config.siteName
21-
}
22-
2317
Layout.propTypes = {
24-
children: PropTypes.object.isRequired,
25-
description: PropTypes.string,
26-
title: PropTypes.string
18+
children: PropTypes.any.isRequired
2719
}

components/common/Meta.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
import config from '@/functions/config'
21
import Head from 'next/head'
3-
import PropTypes from 'prop-types'
42

5-
export default function Meta(props) {
3+
export default function Meta() {
64
return (
75
<Head>
8-
<title>
9-
{props.title} - {props.description}
10-
</title>
116
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
127
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
13-
<meta name="description" content={props.description} />
148
<meta name="msapplication-TileColor" content="#fffff" />
159
<meta name="msapplication-config" content="/favicon/browserconfig.xml" />
1610
<meta name="theme-color" content="#fff" />
@@ -33,34 +27,6 @@ export default function Meta(props) {
3327
/>
3428
<link rel="manifest" href="/favicon/site.webmanifest" />
3529
<link rel="shortcut icon" href="/favicon/favicon.ico" />
36-
<meta name="twitter:card" content="summary" />
37-
<meta name="twitter:url" content={config.siteUrl} />
38-
<meta name="twitter:title" content={props.title} />
39-
<meta name="twitter:description" content={props.description} />
40-
<meta
41-
name="twitter:image"
42-
content={`${config.siteUrl}/favicon/android-icon-192x192.png`}
43-
/>
44-
<meta name="twitter:creator" content={config.author} />
45-
<meta property="og:type" content="website" />
46-
<meta property="og:title" content={props.title} />
47-
<meta property="og:description" content={props.description} />
48-
<meta property="og:site_name" content={props.title} />
49-
<meta property="og:url" content={config.siteUrl} />
50-
<meta
51-
property="og:image"
52-
content={`${config.siteUrl}/favicon/apple-icon.png`}
53-
/>
5430
</Head>
5531
)
5632
}
57-
58-
Meta.defaultProps = {
59-
title: config.siteName,
60-
description: config.siteDescription
61-
}
62-
63-
Meta.propTypes = {
64-
title: PropTypes.string,
65-
description: PropTypes.string
66-
}

functions/config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ const config = {
33
siteDescription: 'The description of this website',
44
siteUrl: 'https://website.vercel.app',
55
author: '@yourname',
6-
navigation: [
7-
{label: 'Home', href: '/'},
8-
{label: 'About', href: '/about'},
9-
{label: 'Apollo', href: '/apollo'},
10-
{label: 'SSG', href: '/ssg'},
11-
{label: 'SSR', href: '/ssr'},
12-
{label: 'ISR', href: '/isr'}
13-
],
6+
navigation: [{label: 'HOOK UP WP NAV MENU', href: '/'}],
147
social: {
158
github: {
169
label: 'Github',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"graphql": "^15.4.0",
6262
"husky": "^4.3.6",
6363
"lint-staged": "^10.5.3",
64+
"next-seo": "^4.17.0",
6465
"next-sitemap": "^1.3.29",
6566
"postcss-flexbugs-fixes": "^4.2.1",
6667
"postcss-preset-env": "^6.7.0",

pages/[...slug].js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Layout from '@/components/common/Layout'
2-
import {Info} from '@/components/molecules/Alert'
3-
import PropTypes from 'prop-types'
41
import getPostTypeStaticPaths from '@/api/wordpress/_global/getPostTypeStaticPaths'
52
import getPostTypeStaticProps from '@/api/wordpress/_global/getPostTypeStaticProps'
3+
import Layout from '@/components/common/Layout'
4+
import {NextSeo} from 'next-seo'
5+
import PropTypes from 'prop-types'
66

77
// Define route post type.
88
const postType = 'page'
@@ -16,15 +16,22 @@ const postType = 'page'
1616
*/
1717
export default function Page({post}) {
1818
return (
19-
<Layout title={post?.title} description={post?.excerpt}>
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+
/>
2034
<div className="container">
21-
<Info>
22-
The content below is sourced from the WordPress REST-API.{' '}
23-
<a href="https://nextjs.org/docs/basic-features/data-fetching#getstaticpaths-static-generation">
24-
Learn more about SSG.
25-
</a>
26-
</Info>
27-
2835
<section>
2936
<article>
3037
<h1 dangerouslySetInnerHTML={{__html: post?.title}} />

pages/_app.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import PropTypes from 'prop-types'
1+
import {useApollo} from '@/api/apolloConfig'
22
import '@/styles/index.css'
33
import {ApolloProvider} from '@apollo/client'
4+
import {DefaultSeo} from 'next-seo'
45
import Error from 'next/error'
5-
import {useApollo} from '@/api/apolloConfig'
6+
import PropTypes from 'prop-types'
67

78
export default function App({Component, pageProps}) {
89
/**
@@ -23,7 +24,27 @@ export default function App({Component, pageProps}) {
2324
{error ? (
2425
<Error statusCode={500} title={errorMessage} />
2526
) : (
26-
<Component {...pageProps} />
27+
<>
28+
<DefaultSeo
29+
title="Next.js WordPress Starter"
30+
description="Query from Yoast SEO"
31+
openGraph={{
32+
type: 'website',
33+
locale: 'en_US',
34+
url: 'Query from Yoast SEO',
35+
site_name: '',
36+
images: [
37+
{
38+
url: 'Query from Yoast SEO',
39+
width: 'Query from Yoast SEO',
40+
height: 'Query from Yoast SEO',
41+
alt: 'Query from Yoast SEO'
42+
}
43+
]
44+
}}
45+
/>
46+
<Component {...pageProps} />
47+
</>
2748
)}
2849
</ApolloProvider>
2950
)

pages/about.js

Lines changed: 0 additions & 43 deletions
This file was deleted.

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/isr.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)