-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
next.config.mjs
129 lines (125 loc) Β· 3.69 KB
/
next.config.mjs
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { withPlaiceholder } from '@plaiceholder/next'
import createPWA from 'next-pwa'
import createMDX from '@next/mdx'
import remarkGFM from 'remark-gfm'
import remarkToc from 'remark-toc'
import rehypeSlug from 'rehype-slug'
import rehypePrettyCode from 'rehype-pretty-code'
import rehypeExternalLinks from 'rehype-external-links'
import rehypeAutoLinkHeadings from 'rehype-autolink-headings'
import rehypeMinify from 'rehype-preset-minify'
import rehypeWrap from 'rehype-wrap-all'
import rehypeImageSize from 'rehype-probe-image-size'
import remarkFrontmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
import remarkReadingTime from 'remark-reading-time'
import readingMdxTime from 'remark-reading-time/mdx.js'
import dark from 'sprinkles-vscode/themes/sprinkles-dark.json' with { type: 'json' }
import light from 'sprinkles-vscode/themes/sprinkles-light.json' with { type: 'json' }
const withPWA = createPWA({
disable: process.env.NODE_ENV === 'development',
dest: 'public',
})
const withMDX = createMDX({
options: {
remarkPlugins: [
remarkGFM,
[remarkToc, { tight: true, maxDepth: 4, ordered: true }],
remarkFrontmatter,
remarkMdxFrontmatter,
remarkReadingTime,
readingMdxTime,
],
rehypePlugins: [
rehypeSlug,
rehypeImageSize,
[rehypeAutoLinkHeadings, { behavior: 'wrap' }],
rehypeExternalLinks,
[
rehypePrettyCode,
{
theme: {
dark,
light,
},
},
],
[rehypeWrap, { selector: 'table', wrapper: 'div.responsiveTable' }],
rehypeMinify,
],
},
})
const cspHeader = `
default-src 'self';
script-src 'self' 'unsafe-eval' 'unsafe-inline';
style-src 'self' 'unsafe-inline';
img-src 'self' blob: data: res.cloudinary.com;
font-src 'self';
object-src 'none';
base-uri 'self';
form-action 'self';
frame-ancestors 'none';
frame-src https://*.codesandbox.io https://*.youtube.com https://stackblitz.com https://*.staticblitz.com;
${process.env.NODE_ENV === 'development' ? '' : 'upgrade-insecure-requests'};
`
export default withPWA(
withPlaiceholder(
withMDX({
pageExtensions: ['ts', 'tsx', 'mdx'],
// https://nextjs.org/docs/app/api-reference/next-config-js/serverExternalPackages
serverExternalPackages: ['uglify-js', 'plaiceholder'],
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'res.cloudinary.com',
port: '',
pathname: '/carloscuesta/image/upload/**',
},
],
deviceSizes: [640, 768, 1024, 1280, 1536],
},
redirects: async () => [
{
source: '/opensource',
destination: '/projects',
permanent: true,
},
{
source: '/follow/linkedin',
destination: 'https://www.linkedin.com/in/crloscuesta',
permanent: true,
},
{
source: '/follow/x',
destination: 'https://twitter.com/crloscuesta',
permanent: true,
},
{
source: '/follow/github',
destination: 'https://github.com/carloscuesta',
permanent: true,
},
],
headers: async () => [
{
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value: cspHeader.replace(/\n/g, ''),
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
],
},
],
}),
),
)