feat: add separate stylesheet for prismjs code block theme
This commit is contained in:
24
lib/mdx.js
24
lib/mdx.js
@ -20,20 +20,6 @@ import rehypePrismPlus from 'rehype-prism-plus'
|
||||
|
||||
const root = process.cwd()
|
||||
|
||||
const tokenClassNames = {
|
||||
tag: 'text-code-red',
|
||||
'attr-name': 'text-code-yellow',
|
||||
'attr-value': 'text-code-green',
|
||||
deleted: 'text-code-red',
|
||||
inserted: 'text-code-green',
|
||||
punctuation: 'text-code-white',
|
||||
keyword: 'text-code-purple',
|
||||
string: 'text-code-green',
|
||||
function: 'text-code-blue',
|
||||
boolean: 'text-code-red',
|
||||
comment: 'text-gray-400 italic',
|
||||
}
|
||||
|
||||
export function getFiles(type) {
|
||||
const prefixPaths = path.join(root, 'data', type)
|
||||
const files = getAllFilesRecursively(prefixPaths)
|
||||
@ -100,16 +86,6 @@ export async function getFileBySlug(type, slug) {
|
||||
rehypeAutolinkHeadings,
|
||||
rehypeKatex,
|
||||
[rehypePrismPlus, { ignoreMissing: true }],
|
||||
() => {
|
||||
return (tree) => {
|
||||
visit(tree, 'element', (node, index, parent) => {
|
||||
let [token, type] = node.properties.className || []
|
||||
if (token === 'token') {
|
||||
node.properties.className = [tokenClassNames[type]]
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
]
|
||||
return options
|
||||
},
|
||||
|
Reference in New Issue
Block a user