Skip to content

Commit faef94d

Browse files
author
Alex Patterson
committed
remove top level config and add to permalink
1 parent 42d1d4c commit faef94d

2 files changed

Lines changed: 22 additions & 24 deletions

File tree

frontend/main/next.config.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff 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
});

frontend/main/src/pages/[...permalink].tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)