Skip to content
This repository was archived by the owner on Feb 14, 2022. It is now read-only.

Commit cd93135

Browse files
committed
update syntax highlighting to match docs site
1 parent a126dd4 commit cd93135

File tree

11 files changed

+2068
-4308
lines changed

11 files changed

+2068
-4308
lines changed

next.config.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
11
const { createLoader } = require('simple-functional-loader')
2-
const rehypePrism = require('@mapbox/rehype-prism')
3-
const visit = require('unist-util-visit')
42
const withBundleAnalyzer = require('@next/bundle-analyzer')({
53
enabled: process.env.ANALYZE === 'true',
64
})
7-
8-
const tokenClassNames = {
9-
tag: 'text-code-red',
10-
'attr-name': 'text-code-yellow',
11-
'attr-value': 'text-code-green',
12-
deleted: 'text-code-red',
13-
inserted: 'text-code-green',
14-
punctuation: 'text-code-white',
15-
keyword: 'text-code-purple',
16-
string: 'text-code-green',
17-
function: 'text-code-blue',
18-
boolean: 'text-code-red',
19-
comment: 'text-gray-400 italic',
20-
}
5+
const withSyntaxHighlighting = require('./remark/withSyntaxHighlighting')
216

227
module.exports = withBundleAnalyzer({
238
pageExtensions: ['js', 'jsx', 'mdx'],
@@ -43,19 +28,7 @@ module.exports = withBundleAnalyzer({
4328
{
4429
loader: '@mdx-js/loader',
4530
options: {
46-
rehypePlugins: [
47-
rehypePrism,
48-
() => {
49-
return (tree) => {
50-
visit(tree, 'element', (node, index, parent) => {
51-
let [token, type] = node.properties.className || []
52-
if (token === 'token') {
53-
node.properties.className = [tokenClassNames[type]]
54-
}
55-
})
56-
}
57-
},
58-
],
31+
remarkPlugins: [withSyntaxHighlighting],
5932
},
6033
},
6134
]

0 commit comments

Comments
 (0)