浏览代码

style: docs code themes

richard1015 4 年之前
父节点
当前提交
b570d6d5cd

+ 1 - 1
package.json

@@ -99,7 +99,7 @@
     "ts-jest": "^26.5.5",
     "typescript": "^4.1.5",
     "vite": "^2.3.4",
-    "vite-plugin-md": "^0.6.7",
+    "vite-plugin-md": "^0.11.0",
     "vue-jest": "^5.0.0-alpha.7"
   },
   "eslintConfig": {

+ 0 - 1
src/packages/__VUE/cell/doc.md

@@ -12,7 +12,6 @@ import { Cell,Icon } from '@nutui/nutui';
 
 const app = createApp();
 app.use(Cell).use(Icon);
-
 ```
 
 ## 代码示例

+ 1 - 1
src/sites/assets/styles/highlight.scss

@@ -40,7 +40,7 @@ pre {
 .hljs-template-tag,
 .hljs-template-variable,
 .hljs-addition {
-  color: $nutui-doc-green;
+  color: $nutui-doc-red;
 }
 
 .hljs-comment,

+ 1 - 1
src/sites/assets/styles/md-style.scss

@@ -145,7 +145,7 @@
     }
 
     em {
-      color: $nutui-doc-green;
+      color: $nutui-doc-red;
       font-size: 14px;
       font-family: $nutui-doc-code-font-family;
       font-style: normal;

+ 1 - 1
src/sites/assets/styles/variables.scss

@@ -91,7 +91,7 @@ $nutui-doc-black: #323233;
 $nutui-doc-blue: #1989fa;
 $nutui-doc-purple: #8080ff;
 $nutui-doc-fuchsia: #a7419e;
-$nutui-doc-green: #4fc08d;
+$nutui-doc-red: #fa2400;
 $nutui-doc-text-color: #666666;
 $nutui-doc-text-light-blue: rgba(69, 90, 100, 0.6);
 $nutui-doc-background-color: #f7f8fa;

+ 16 - 1
vite.config.ts

@@ -4,6 +4,7 @@ import legacy from '@vitejs/plugin-legacy';
 import Markdown from 'vite-plugin-md';
 import path from 'path';
 import config from './package.json';
+const hljs = require('highlight.js'); // https://highlightjs.org/
 const resolve = path.resolve;
 // https://vitejs.dev/config/
 export default defineConfig({
@@ -34,7 +35,21 @@ export default defineConfig({
     vue({
       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({
       targets: ['defaults', 'not IE 11']
     })