File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,28 +21,4 @@ module.exports = withBundleAnalyzer({
2121 }
2222 return config ;
2323 } ,
24- async redirects ( ) {
25- return [
26- {
27- source : '/courses/:permalink*' ,
28- destination : '/course/:permalink*' ,
29- permanent : true ,
30- } ,
31- {
32- source : '/tutorials/:permalink*' ,
33- destination : '/tutorial/:permalink*' ,
34- permanent : true ,
35- } ,
36- {
37- source : '/podcasts/:permalink*' ,
38- destination : '/podcast/:permalink*' ,
39- permanent : true ,
40- } ,
41- // {
42- // source: '/:permalink',
43- // destination: '/post/:permalink',
44- // permanent: true,
45- // },
46- ] ;
47- } ,
4824} ) ;
Original file line number Diff line number Diff line change @@ -88,6 +88,28 @@ export async function getStaticProps({
8888 let type = params . permalink [ 0 ] as PostType ;
8989 let slug = params . permalink [ 1 ] as string ;
9090
91+ // Redirect plural page types
92+ if ( [ 'podcasts' , 'tutorials' , 'courses' ] . includes ( type ) && slug ) {
93+ let dest ;
94+ switch ( type as string ) {
95+ case 'podcasts' :
96+ dest = 'podcast' ;
97+ break ;
98+ case 'tutorials' :
99+ dest = 'tutorial' ;
100+ break ;
101+ case 'courses' :
102+ dest = 'course' ;
103+ break ;
104+ }
105+ return {
106+ redirect : {
107+ destination : `/${ dest } /${ slug } ` ,
108+ permanent : true ,
109+ } ,
110+ } ;
111+ }
112+
91113 // Make assumption that this should be a base page.
92114 if ( type && ! slug ) {
93115 slug = type ;
You can’t perform that action at this time.
0 commit comments