|
@@ -4,6 +4,7 @@ import legacy from '@vitejs/plugin-legacy';
|
|
|
import Markdown from 'vite-plugin-md';
|
|
import Markdown from 'vite-plugin-md';
|
|
|
import path from 'path';
|
|
import path from 'path';
|
|
|
import config from './package.json';
|
|
import config from './package.json';
|
|
|
|
|
+const hljs = require('highlight.js'); // https://highlightjs.org/
|
|
|
const resolve = path.resolve;
|
|
const resolve = path.resolve;
|
|
|
// https://vitejs.dev/config/
|
|
// https://vitejs.dev/config/
|
|
|
export default defineConfig({
|
|
export default defineConfig({
|
|
@@ -34,7 +35,21 @@ export default defineConfig({
|
|
|
vue({
|
|
vue({
|
|
|
include: [/\.vue$/, /\.md$/]
|
|
include: [/\.vue$/, /\.md$/]
|
|
|
}),
|
|
}),
|
|
|
- Markdown(),
|
|
|
|
|
|
|
+ Markdown({
|
|
|
|
|
+ // default options passed to markdown-it
|
|
|
|
|
+ // see: https://markdown-it.github.io/markdown-it/
|
|
|
|
|
+ markdownItOptions: {
|
|
|
|
|
+ highlight: function (str, lang) {
|
|
|
|
|
+ if (lang && hljs.getLanguage(lang)) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ return hljs.highlight(lang, str).value;
|
|
|
|
|
+ } catch (__) {}
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return ''; // 使用额外的默认转义
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }),
|
|
|
legacy({
|
|
legacy({
|
|
|
targets: ['defaults', 'not IE 11']
|
|
targets: ['defaults', 'not IE 11']
|
|
|
})
|
|
})
|