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

Commit a91b5b0

Browse files
committed
Add category archive query, handling
1 parent 1402d08 commit a91b5b0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

api/wordpress/_global/getPostTypeTaxonomyArchive.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {postTypes} from './postTypes'
33
import formatDefaultSeoData from '@/functions/formatDefaultSeoData'
44
import getMenus from '../menus/getMenus'
55
import queryPostsByTag from '../tags/queryPostsByTag'
6+
import queryPostsByCategory from '../categories/queryPostsByCategory'
67

78
/**
89
* Retrieve post taxnomy archive.
@@ -30,6 +31,7 @@ export default async function getPostTypeTaxonomyArchive(
3031
) {
3132
// Define single post query based on taxonomy.
3233
const postTypeQuery = {
34+
category: queryPostsByCategory,
3335
tag: queryPostsByTag
3436
}
3537

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import {gql} from '@apollo/client'
2+
import defaultPageData from '../_partials/defaultPageData'
3+
import {archivePostFragment, archivePosts} from '../posts/queryPostsArchive'
4+
import seoPostFields from '../_partials/seoPostFields'
5+
6+
// Query: retrieve posts category archive.
7+
const queryPostsByCategory = gql`
8+
query GET_POSTS_BY_CATEGORY(
9+
$first: Int
10+
$last: Int
11+
$after: String
12+
$before: String
13+
$orderBy: PostObjectsConnectionOrderbyEnum = DATE
14+
$order: OrderEnum = DESC
15+
$imageSize: MediaItemSizeEnum = THUMBNAIL
16+
$id: ID!
17+
$idType: CategoryIdType = SLUG
18+
) {
19+
${defaultPageData}
20+
category(id: $id, idType: $idType) {
21+
${seoPostFields}
22+
${archivePosts}
23+
}
24+
}
25+
${archivePostFragment}
26+
`
27+
28+
export default queryPostsByCategory

0 commit comments

Comments
 (0)