1+ import { fileURLToPath } from 'url'
2+ import { dirname } from 'path'
3+ import { createRequire } from 'module'
4+ import rehypeShiki from '@shikijs/rehype'
5+ import { transformerTwoslash } from '@shikijs/twoslash'
6+
7+ const require = createRequire ( import . meta. url )
8+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) )
9+
110if ( process . env . BOOTSTRAPPING ) {
211 const chalk = require ( "chalk" )
312 const readline = require ( "readline" )
@@ -14,16 +23,17 @@ if (process.env.BOOTSTRAPPING) {
1423
1524require ( "./scripts/ensureDepsAreBuilt" )
1625
17- const ts = require ( "typescript" ) ;
18-
1926// https://github.com/gatsbyjs/gatsby/issues/1457
2027require ( "ts-node" ) . register ( { files : true } )
21- const { join } = require ( "path" )
2228
23- module . exports = {
29+ export default {
2430 siteMetadata : {
2531 siteUrl : `https://www.typescriptlang.org/` ,
2632 } ,
33+ graphqlTypegen : {
34+ // Ensure it works in a monorepo
35+ typesOutputPath : `${ __dirname } /src/__generated__/gatsby-types.ts` ,
36+ } ,
2737 flags : {
2838 DEV_SSR : false ,
2939 } ,
@@ -52,17 +62,6 @@ module.exports = {
5262 // Support for downloading or pre-caching pages, needed for PWAs
5363 // "gatsby-plugin-offline",
5464
55- // Creates TS types for queries during `gatsby dev`
56- {
57- resolve : "gatsby-plugin-typegen" ,
58- options : {
59- // Ensure it works in a monorepo
60- outputPath : __dirname + "/src/__generated__/gatsby-types.ts" ,
61- } ,
62- } ,
63-
64- // Support ts/tsx files in src
65- "gatsby-plugin-typescript" ,
6665 // SEO
6766 {
6867 resolve : `gatsby-plugin-sitemap` ,
@@ -134,41 +133,42 @@ module.exports = {
134133 } ,
135134
136135 // Markdown support, and markdown + react
137- // `gatsby-plugin-mdx`,
138136 {
139- resolve : `gatsby-transformer-remark ` ,
137+ resolve : `gatsby-plugin-mdx ` ,
140138 options : {
141- plugins : [
142- {
143- resolve : `gatsby-remark-images` ,
144- options : {
145- maxWidth : 590 ,
146- } ,
147- } ,
148- {
149- resolve : `gatsby-remark-responsive-iframe` ,
150- options : {
151- wrapperStyle : `margin-bottom: 1.0725rem` ,
152- } ,
153- } ,
154- "gatsby-remark-autolink-headers" ,
155- {
156- resolve : "gatsby-remark-shiki-twoslash" ,
157- options : {
158- theme : require ( "./lib/themes/typescript-beta-light.json" ) ,
159- addTryButton : true ,
160- defaultOptions : {
161- noErrorValidation : true ,
139+ extensions : [ `.md` , `.mdx` ] ,
140+ mdxOptions : {
141+ extensions : [ `.md` , `.mdx` ] ,
142+ remarkPlugins : [
143+ {
144+ resolve : `gatsby-remark-images` ,
145+ options : {
146+ maxWidth : 590 ,
162147 } ,
163- defaultCompilerOptions : {
164- types : [ ] ,
165- target : ts . ScriptTarget . ES2020 ,
148+ } ,
149+ {
150+ resolve : `gatsby-remark-responsive-iframe` ,
151+ options : {
152+ wrapperStyle : `margin-bottom: 1.0725rem` ,
166153 } ,
167154 } ,
168- } ,
169- "gatsby-remark-copy-linked-files" ,
170- "gatsby-remark-smartypants" ,
171- ] ,
155+ "gatsby-remark-autolink-headers" ,
156+ "gatsby-remark-copy-linked-files" ,
157+ "gatsby-remark-smartypants" ,
158+ ] ,
159+ rehypePlugins : [
160+ [
161+ rehypeShiki ,
162+ {
163+ themes : {
164+ light : 'light-plus' ,
165+ dark : 'dark-plus' ,
166+ } ,
167+ transformers : [ transformerTwoslash ( { explicitTrigger : true } ) ] ,
168+ } ,
169+ ] ,
170+ ] ,
171+ } ,
172172 } ,
173173 } ,
174174 // Finds auto-generated <a>s and converts them
0 commit comments