feat: add rehype-prism-plus and docs

This commit is contained in:
Timothy Lin
2021-06-29 18:09:37 +08:00
parent f7cda6f536
commit fbd68ec616
6 changed files with 228 additions and 73 deletions

View File

@ -86,7 +86,7 @@ export async function getFileBySlug(type, slug) {
options.rehypePlugins = [
...(options.rehypePlugins ?? []),
require('rehype-katex'),
require('@mapbox/rehype-prism'),
[require('rehype-prism-plus'), { ignoreMissing: true }],
() => {
return (tree) => {
visit(tree, 'element', (node, index, parent) => {

View File

@ -4,8 +4,8 @@ module.exports = function (options) {
return (tree) =>
visit(tree, 'code', (node, index) => {
const nodeLang = node.lang || ''
let language = '',
title = ''
let language = ''
let title = ''
if (nodeLang.includes(':')) {
language = nodeLang.slice(0, nodeLang.search(':'))