From 0b521d357c4f5c6b6781ac2860ae17ff26524a83 Mon Sep 17 00:00:00 2001 From: StEve Young <2747745470@qq.com> Date: Thu, 21 Nov 2019 14:44:30 +0800 Subject: [PATCH] perf: close #16, use v-html to render code at runtime in DemoAndCode.vue (#18) --- babel.config.js | 2 +- docs/.vuepress/config.js | 4 +- jest.config.js | 2 +- package.json | 20 ++++----- src/DemoAndCode.vue | 41 ++++++++---------- src/constants.js | 2 +- src/highlight.js | 46 +++++++++++---------- src/index.js | 10 +---- test/__snapshots__/DemoAndCode.test.js.snap | 13 +++++- test/utils.test.js | 10 ++--- 10 files changed, 77 insertions(+), 73 deletions(-) diff --git a/babel.config.js b/babel.config.js index f221db9..d234ef3 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,7 @@ module.exports = { presets: [ [ '@babel/preset-env', - { targets: { 'node': 'current' } }, + { targets: { node: 'current' } }, ], ], }, diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 6fb7452..e4b26e1 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -16,8 +16,8 @@ module.exports = { }, }, head: [ - ['link', { rel: 'icon', href: `/favicon.ico` }], - ['link', { rel: 'stylesheet', href: `https://unpkg.com/animate.css@3.7.0/animate.min.css` }], + ['link', { rel: 'icon', href: '/favicon.ico' }], + ['link', { rel: 'stylesheet', href: 'https://unpkg.com/animate.css@3.7.0/animate.min.css' }], ], plugins: [ ['smooth-scroll'], diff --git a/jest.config.js b/jest.config.js index ba2834f..563b5dc 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,7 +8,7 @@ module.exports = { '!src/highlight.js', '!src/enhanceAppFile.js', ], - coveragePathIgnorePatterns: [ '/__snapshots__/' ], + coveragePathIgnorePatterns: ['/__snapshots__/'], transform: { '^.+\\.vue$': 'vue-jest', '^.+\\.jsx?$': 'babel-jest', diff --git a/package.json b/package.json index 3b8fd32..a77b717 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vuepress-plugin-demo-code", - "version": "0.3.7", + "version": "0.4.0", "description": "📝 Demo and code plugin for vuepress", "main": "src/index.js", "files": [ @@ -37,35 +37,35 @@ "prismjs": "^1.17.1" }, "devDependencies": { - "@babel/core": "^7.6.4", - "@babel/preset-env": "^7.6.3", + "@babel/core": "^7.7.2", + "@babel/preset-env": "^7.7.1", "@commitlint/cli": "^8.2.0", "@commitlint/config-conventional": "^8.2.0", "@vue/test-utils": "^1.0.0-beta.29", - "all-contributors-cli": "^6.9.1", + "all-contributors-cli": "^6.11.0", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^10.0.3", "codecov": "^3.6.1", "cross-env": "^6.0.3", - "eslint": "^6.5.1", + "eslint": "^6.6.0", "eslint-config-standard": "^14.1.0", "eslint-config-vue": "^2.0.2", "eslint-plugin-import": "^2.18.2", "eslint-plugin-node": "^10.0.0", "eslint-plugin-promise": "^4.2.1", "eslint-plugin-standard": "^4.0.1", - "eslint-plugin-vue": "^5.2.3", + "eslint-plugin-vue": "^6.0.1", "gh-pages": "^2.1.1", - "husky": "^3.0.8", + "husky": "^3.1.0", "jest": "^24.9.0", "jest-serializer-vue": "^2.0.2", "jest-transform-stub": "^2.0.0", - "lint-staged": "^9.4.2", + "lint-staged": "^9.4.3", "markdown-it-include": "^1.1.0", "rimraf": "^3.0.0", "vue-jest": "^3.0.5", - "vuepress": "^1.1.0", - "vuepress-plugin-smooth-scroll": "^0.0.4" + "vuepress": "^1.2.0", + "vuepress-plugin-smooth-scroll": "^0.0.7" }, "keywords": [ "vue", diff --git a/src/DemoAndCode.vue b/src/DemoAndCode.vue index 0a497e8..34443ec 100644 --- a/src/DemoAndCode.vue +++ b/src/DemoAndCode.vue @@ -25,13 +25,17 @@