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

Commit eefdc47

Browse files
committed
Filter out custom routes
1 parent 48eec17 commit eefdc47

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

api/wordpress/_global/getPostTypeStaticPaths.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ export default async function getPostTypeStaticPaths(postType) {
4545
// Process paths.
4646
const paths = !posts?.data?.[pluralName]?.edges
4747
? []
48-
: posts.data[pluralName].edges.map((post) => {
49-
// Trim leading and trailing slashes then split into array on inner slashes.
50-
const slug = post.node[pathField].replace(/^\/|\/$/g, '').split('/')
48+
: posts.data[pluralName].edges
49+
.map((post) => {
50+
// Trim leading and trailing slashes then split into array on inner slashes.
51+
const slug = post.node[pathField].replace(/^\/|\/$/g, '').split('/')
5152

52-
return {
53-
params: {
54-
slug
53+
return {
54+
params: {
55+
slug
56+
}
5557
}
56-
}
57-
})
58+
})
59+
// Filter out certain posts with custom routes (e.g., homepage).
60+
.filter((post) => !!post.params.slug.join('/').length)
5861

5962
return {
6063
paths,

0 commit comments

Comments
 (0)