forked from leerob/next-mdx-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
37 lines (31 loc) · 863 Bytes
/
next.config.ts
File metadata and controls
37 lines (31 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import type { NextConfig } from 'next';
import createMDX from '@next/mdx';
import postgres from 'postgres';
export const sql = postgres(process.env.POSTGRES_URL!, {
ssl: 'allow'
});
const nextConfig: NextConfig = {
pageExtensions: ['mdx', 'ts', 'tsx'],
async redirects() {
if (!process.env.POSTGRES_URL) {
return [];
}
let redirects = await sql`
SELECT source, destination, permanent
FROM redirects;
`;
return redirects.map(({ source, destination, permanent }) => ({
source,
destination,
permanent: !!permanent
}));
},
// Note: Using the Rust compiler means we cannot use
// rehype or remark plugins. If you need them, remove
// the `experimental.mdxRs` flag.
experimental: {
mdxRs: { mdxType: 'gfm' }
}
};
const withMDX = createMDX({});
export default withMDX(nextConfig);