@@ -3,20 +3,23 @@ import { withSentryConfig } from '@sentry/nextjs'
3
3
//import WithBundleAnalyzer from '@next/bundle-analyzer'
4
4
import { PHASE_DEVELOPMENT_SERVER } from 'next/constants.js'
5
5
import createMdx from '@next/mdx'
6
- import { remarkTableOfContents } from 'remark-table-of-contents'
7
- import rehypeAutolinkHeadings from 'rehype-autolink-headings'
6
+ import { remarkTableOfContents , type IRemarkTableOfContentsOptions as remarkTableOfContentsOptionsType } from 'remark-table-of-contents'
7
+ import rehypeAutolinkHeadings , { type Options as rehypeAutolinkHeadingsOptionsType } from 'rehype-autolink-headings'
8
+ import { type ElementContent } from 'hast'
8
9
import { fromHtmlIsomorphic } from 'hast-util-from-html-isomorphic'
9
10
import { toString as hastToString } from 'mdast-util-to-string'
10
11
import rehypeSlug from 'rehype-slug'
11
- import remarkGfm from 'remark-gfm'
12
- import { rehypeGithubAlerts } from 'rehype-github-alerts'
12
+ import remarkGfm , { type Options as remarkGfmOptionsType } from 'remark-gfm'
13
+ import { rehypeGithubAlerts , type DefaultBuildType as rehypeGithubAlertsDefaultBuildType , type IOptions as rehypeGithubAlertsOptionsType } from 'rehype-github-alerts'
13
14
import rehypeMDXImportMedia from 'rehype-mdx-import-media'
14
15
import remarkFrontmatter from 'remark-frontmatter'
15
16
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
16
- import { rehypePrettyCode } from 'rehype-pretty-code'
17
+ import { rehypePrettyCode , type Options as rehypePrettyCodeOptionsType } from 'rehype-pretty-code'
17
18
import { transformerNotationDiff } from '@shikijs/transformers'
19
+ import type { ShikiTransformer } from 'shiki'
20
+ import { NextConfig } from 'next'
18
21
19
- const nextConfig = ( phase ) => {
22
+ const nextConfig = ( phase : string ) => {
20
23
21
24
// to use the bundle analyzer uncomment the following lines
22
25
// then uncomment the return to use withBundleAnalyzer
@@ -26,27 +29,25 @@ const nextConfig = (phase) => {
26
29
})*/
27
30
28
31
// https://rehype-pretty-code.netlify.app/
29
- /** @type {import('rehype-pretty-code').Options } */
30
- const rehypePrettyCodeOptions = {
32
+ const rehypePrettyCodeOptions : rehypePrettyCodeOptionsType = {
31
33
// VSCode "SynthWave '84" theme
32
34
theme : 'synthwave-84' ,
33
35
// Keep the background or use a custom background color?
34
36
keepBackground : true ,
35
37
tokensMap : {
36
- ' function' : 'entity.name.function' ,
37
- ' string' : 'string' ,
38
- ' key' : '.meta.object-literal.key' ,
38
+ function : 'entity.name.function' ,
39
+ string : 'string' ,
40
+ key : '.meta.object-literal.key' ,
39
41
} ,
40
42
defaultLang : {
41
43
block : 'tsx' ,
42
44
inline : 'shell' ,
43
45
} ,
44
- transformers : [ transformerNotationDiff ( ) ] ,
46
+ transformers : [ transformerNotationDiff ( ) as ShikiTransformer ] ,
45
47
}
46
48
47
49
// https://github.com/chrisweb/remark-table-of-contents#options
48
- /** @type {import('remark-table-of-contents').IRemarkTableOfContentsOptions } */
49
- const remarkTableOfContentsOptions = {
50
+ const remarkTableOfContentsOptions : remarkTableOfContentsOptionsType = {
50
51
containerAttributes : {
51
52
id : 'articleToc' ,
52
53
} ,
@@ -57,32 +58,30 @@ const nextConfig = (phase) => {
57
58
}
58
59
59
60
// https://github.com/rehypejs/rehype-autolink-headings#api
60
- const rehypeAutolinkHeadingsOptions = {
61
+ const rehypeAutolinkHeadingsOptions : rehypeAutolinkHeadingsOptionsType = {
61
62
behavior : 'append' ,
62
63
properties : ( node ) => {
63
64
//console.log(node)
64
65
const headingText = hastToString ( node . children [ 0 ] )
65
66
return {
66
- class : 'headingAnchor' ,
67
+ ' class' : 'headingAnchor' ,
67
68
'aria-label' : 'Heading permalink for: ' + headingText ,
68
- title : 'Heading permalink for: ' + headingText ,
69
+ ' title' : 'Heading permalink for: ' + headingText ,
69
70
}
70
71
} ,
71
72
content : fromHtmlIsomorphic (
72
73
'<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24" class="icon iconLink" aria-hidden="true"><path d="M11 17H7q-2.075 0-3.537-1.463Q2 14.075 2 12t1.463-3.538Q4.925 7 7 7h4v2H7q-1.25 0-2.125.875T4 12q0 1.25.875 2.125T7 15h4Zm-3-4v-2h8v2Zm5 4v-2h4q1.25 0 2.125-.875T20 12q0-1.25-.875-2.125T17 9h-4V7h4q2.075 0 3.538 1.462Q22 9.925 22 12q0 2.075-1.462 3.537Q19.075 17 17 17Z"/></svg>' ,
73
74
{ fragment : true }
74
- ) . children ,
75
+ ) . children as ElementContent [ ] ,
75
76
}
76
77
77
78
// https://github.com/remarkjs/remark-gfm
78
- /** @type {import('remark-gfm').Options } */
79
- const remarkGfmOptions = {
79
+ const remarkGfmOptions : remarkGfmOptionsType = {
80
80
singleTilde : false ,
81
81
}
82
82
83
83
// https://github.com/chrisweb/rehype-github-alerts
84
- /** @type {import('rehype-github-alerts').DefaultBuildType } */
85
- const myGithubAlertBuild = ( alertOptions , originalChildren ) => {
84
+ const myGithubAlertBuild : rehypeGithubAlertsDefaultBuildType = ( alertOptions , originalChildren ) => {
86
85
87
86
const alert = {
88
87
type : 'element' ,
@@ -135,12 +134,12 @@ const nextConfig = (phase) => {
135
134
] ,
136
135
}
137
136
138
- return alert
137
+ return alert as ElementContent
139
138
140
139
}
141
140
142
- /** @type { import(' rehype-github-alerts').IOptions } */
143
- const rehypeGithubAlertsOptions = {
141
+ // https://github.com/chrisweb/ rehype-github-alerts#options
142
+ const rehypeGithubAlertsOptions : rehypeGithubAlertsOptionsType = {
144
143
supportLegacy : false ,
145
144
build : myGithubAlertBuild ,
146
145
alerts : [
@@ -174,8 +173,7 @@ const nextConfig = (phase) => {
174
173
} ,
175
174
} )
176
175
177
- /** @type {import('next').NextConfig } */
178
- const nextConfigOptions = {
176
+ const nextConfigOptions : NextConfig = {
179
177
reactStrictMode : true ,
180
178
poweredByHeader : false ,
181
179
experimental : {
@@ -202,7 +200,7 @@ const nextConfig = (phase) => {
202
200
reactCompiler : true ,
203
201
// experimental partial prerendering
204
202
// https://nextjs.org/docs/messages/ppr-preview
205
- ppr : true ,
203
+ ppr : false ,
206
204
// experimental typescript "statically typed links"
207
205
// https://nextjs.org/docs/app/api-reference/next-config-js/typedRoutes
208
206
typedRoutes : true ,
@@ -227,6 +225,7 @@ const nextConfig = (phase) => {
227
225
eslint : {
228
226
ignoreDuringBuilds : true ,
229
227
} ,
228
+ // eslint-disable-next-line @typescript-eslint/require-await
230
229
headers : async ( ) => {
231
230
return [
232
231
{
@@ -253,6 +252,7 @@ const nextConfig = (phase) => {
253
252
} ,
254
253
]
255
254
} ,
255
+ // eslint-disable-next-line @typescript-eslint/require-await
256
256
redirects : async ( ) => {
257
257
return [
258
258
{
@@ -269,7 +269,7 @@ const nextConfig = (phase) => {
269
269
270
270
}
271
271
272
- const securityHeadersConfig = ( phase ) => {
272
+ const securityHeadersConfig = ( phase : string ) => {
273
273
274
274
const cspReportOnly = false
275
275
const reportingUrl = 'https://o4504017992482816.ingest.us.sentry.io/api/4506763918770176/security/?sentry_key=daf0befe66519725bbe2ad707a11bbb3'
@@ -278,6 +278,7 @@ const securityHeadersConfig = (phase) => {
278
278
279
279
const cspHeader = ( ) => {
280
280
281
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
281
282
const upgradeInsecure = ( ! isDev && ! cspReportOnly ) ? 'upgrade-insecure-requests;' : ''
282
283
283
284
// report directive to be added at the end
@@ -373,6 +374,7 @@ const securityHeadersConfig = (phase) => {
373
374
const headers = [
374
375
...extraSecurityHeaders ,
375
376
{
377
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
376
378
key : cspReportOnly ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy' ,
377
379
value : cspHeader ( ) . replace ( / \n / g, '' ) ,
378
380
} ,
0 commit comments