@@ -31,10 +31,21 @@ export function cleanupRedirects(movedPages) {
31
31
/**
32
32
* Reads Notion specific redirections from data/notion_migration.yaml.
33
33
*
34
- * @returns {redirections: {source: string, destination: string}[] }
34
+ * @returns {redirections: {source: string, destination: string, force: true }[] }
35
35
*/
36
36
async function readNotionMigrationRedirects ( ) {
37
- return load ( await readFile ( 'data/notion_migration.yaml' , 'utf8' ) )
37
+ const data = load ( await readFile ( 'data/notion_migration.yaml' , 'utf8' ) )
38
+
39
+ // While NextJS is okay if content exists when setting up a redirection,
40
+ // Netlify doesn't: it will skip the redirection entirely if it finds
41
+ // existing content.
42
+ // To go around that, we add a new field 'force' that the script that
43
+ // generate the final _redirects file used by Netlify uses to append
44
+ // 301! on that entry, effectively forcing the redirection.
45
+ for ( let entry of data . redirections ) {
46
+ entry [ "force" ] = true
47
+ }
48
+ return data
38
49
}
39
50
40
51
/**
@@ -46,12 +57,11 @@ export default async function redirects() {
46
57
const movedPages = await getMovedPagesFromHistory ( )
47
58
const notionRedirections = await readNotionMigrationRedirects ( )
48
59
return cleanupRedirects ( [
49
- ...notionRedirections . redirections ,
50
60
...movedPages ,
51
61
// Add custom redirects
52
62
{
53
63
source : '/careers' ,
54
64
destination : 'https://about.sourcegraph.com/jobs' ,
55
65
} ,
56
- ] )
66
+ ] ) . concat ( notionRedirections . redirections ) // we skip the cleanup because notion redirects are always going outside.
57
67
}
0 commit comments