@@ -9,6 +9,45 @@ import queryPortfoliosArchive from '../portfolios/queryPortfoliosArchive'
9
9
import queryTestimonialsArchive from '../testimonials/queryTestimonialsArchive'
10
10
import formatDefaultSeoData from '@/functions/formatDefaultSeoData'
11
11
12
+ // Define SEO for archives.
13
+ export const archiveSeo = {
14
+ career : {
15
+ title : 'Careers' ,
16
+ description : '' ,
17
+ route : 'careers'
18
+ } ,
19
+ event : {
20
+ title : 'Events' ,
21
+ description : '' ,
22
+ route : 'events'
23
+ } ,
24
+ portfolio : {
25
+ title : 'Portfolio' ,
26
+ description : '' ,
27
+ route : 'portfolio'
28
+ } ,
29
+ post : {
30
+ title : 'Blog' ,
31
+ description : '' ,
32
+ route : 'blog'
33
+ } ,
34
+ service : {
35
+ title : 'Services' ,
36
+ description : '' ,
37
+ route : 'service'
38
+ } ,
39
+ team : {
40
+ title : 'Team Members' ,
41
+ description : '' ,
42
+ route : 'team'
43
+ } ,
44
+ testimonial : {
45
+ title : 'Testimonials' ,
46
+ description : '' ,
47
+ route : 'testimonial'
48
+ }
49
+ }
50
+
12
51
/**
13
52
* Retrieve post archive.
14
53
*
@@ -97,14 +136,23 @@ export default async function getPostTypeArchive(
97
136
// Flatten posts array to include inner node post data.
98
137
response . posts = data . edges . map ( ( post ) => post . node )
99
138
100
- // Attempt to use posts page for blog, default to front page.
101
- const defaultPage =
102
- 'post' === postType && homepageSettings ?. postsPage
103
- ? homepageSettings . postsPage
104
- : homepageSettings ?. frontPage
105
-
106
- // Populate post object.
107
- response . post = { ...defaultPage }
139
+ // Attempt to use posts page for blog, default to custom SEO.
140
+ response . post = {
141
+ seo :
142
+ 'post' === postType && homepageSettings ?. postsPage ?. seo
143
+ ? homepageSettings . postsPage . seo
144
+ : {
145
+ title : `${ archiveSeo ?. [ postType ] ?. title } - ${
146
+ response . defaultSeo ?. openGraph ?. siteName ?? ''
147
+ } `,
148
+ metaDesc : archiveSeo ?. [ postType ] ?. description ,
149
+ canonical : `${ response . defaultSeo ?. openGraph ?. url ?? '' } /${
150
+ archiveSeo ?. [ postType ] ?. route
151
+ } `,
152
+ metaRobotsNofollow : 'follow' ,
153
+ metaRobotsNoindex : 'index'
154
+ }
155
+ }
108
156
109
157
// Extract pagination data.
110
158
response . pagination = data . pageInfo
0 commit comments