This repository was archived by the owner on Feb 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -41,21 +41,24 @@ export default async function getPostTypeStaticPaths(postType) {
41
41
const posts = await apolloClient . query ( { query} )
42
42
43
43
// Process paths.
44
- return {
45
- paths : ! posts ?. data ?. [ pluralName ] ?. nodes
46
- ? [ ]
47
- : posts . data [ pluralName ] . nodes . map ( ( post ) => {
48
- // Use string path for non-hierarchical posts, split into array if hierarchical.
49
- const slug = ! isHierarchical
50
- ? post [ pathField ]
51
- : post [ pathField ] . replace ( / ^ \/ | \/ $ / g, '' ) . split ( '/' )
52
-
53
- return {
54
- params : {
55
- slug
56
- }
44
+ const paths = ! posts ?. data ?. [ pluralName ] ?. nodes
45
+ ? [ ]
46
+ : posts . data [ pluralName ] . nodes . map ( ( post ) => {
47
+ // Use path field as-is for non-hierarchical post types.
48
+ // Trim leading and trailing slashes then split into array on inner slashes for hierarchical post types.
49
+ const slug = ! isHierarchical
50
+ ? post [ pathField ]
51
+ : post [ pathField ] . replace ( / ^ \/ | \/ $ / g, '' ) . split ( '/' )
52
+
53
+ return {
54
+ params : {
55
+ slug
57
56
}
58
- } ) ,
57
+ }
58
+ } )
59
+
60
+ return {
61
+ paths,
59
62
fallback : false
60
63
}
61
64
}
You can’t perform that action at this time.
0 commit comments