mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-10-27 01:32:10 +08:00 
			
		
		
		
	feat(markdown-loader): compatible with vue 3
This commit is contained in:
		
							parent
							
								
									6abb2fc081
								
							
						
					
					
						commit
						d697026b2c
					
				| @ -50,7 +50,7 @@ | |||||||
|     "@nuxt/friendly-errors-webpack-plugin": "^2.5.0", |     "@nuxt/friendly-errors-webpack-plugin": "^2.5.0", | ||||||
|     "@types/jest": "^25.2.1", |     "@types/jest": "^25.2.1", | ||||||
|     "@vant/eslint-config": "^2.2.2", |     "@vant/eslint-config": "^2.2.2", | ||||||
|     "@vant/markdown-loader": "^2.3.0", |     "@vant/markdown-loader": "^3.0.0-alpha.0", | ||||||
|     "@vant/markdown-vetur": "^2.0.1", |     "@vant/markdown-vetur": "^2.0.1", | ||||||
|     "@vant/stylelint-config": "^1.3.0", |     "@vant/stylelint-config": "^1.3.0", | ||||||
|     "@vant/touch-emulator": "^1.2.0", |     "@vant/touch-emulator": "^1.2.0", | ||||||
|  | |||||||
| @ -1640,13 +1640,13 @@ | |||||||
|     eslint-plugin-import "^2.20.2" |     eslint-plugin-import "^2.20.2" | ||||||
|     eslint-plugin-vue "^6.2.2" |     eslint-plugin-vue "^6.2.2" | ||||||
| 
 | 
 | ||||||
| "@vant/markdown-loader@^2.3.0": | "@vant/markdown-loader@^3.0.0-alpha.0": | ||||||
|   version "2.3.0" |   version "3.0.0-alpha.0" | ||||||
|   resolved "https://registry.yarnpkg.com/@vant/markdown-loader/-/markdown-loader-2.3.0.tgz#ea8ab4d8d41609839b40b817bc3a598cf13f9920" |   resolved "https://registry.npmjs.org/@vant/markdown-loader/-/markdown-loader-3.0.0-alpha.0.tgz#a14fa5c6bf4ffd57916855210dffc0daf8d9d6cb" | ||||||
|   integrity sha512-efNAnJMQbX3yP0+/zvnlYda+xIATLl+T9BXOB179M8KkS3hKk0b8tYHYVeLmdCLbJFeVd8bVXICILIplOYQJ5A== |   integrity sha512-cDDXfYhyS6yfVtqx+hwgN4blqd/+V1mYsvtDKsrpAZnirFhWfVFWeNZEjXPN6JYfXk3rEprEepjY/FPtCJG2EQ== | ||||||
|   dependencies: |   dependencies: | ||||||
|     front-matter "^3.0.2" |     front-matter "^3.0.2" | ||||||
|     highlight.js "^9.16.2" |     highlight.js "^9.17.1" | ||||||
|     loader-utils "^1.2.3" |     loader-utils "^1.2.3" | ||||||
|     markdown-it "^10.0.0" |     markdown-it "^10.0.0" | ||||||
|     markdown-it-anchor "^5.2.5" |     markdown-it-anchor "^5.2.5" | ||||||
| @ -5497,9 +5497,9 @@ he@^1.2.0: | |||||||
|   resolved "https://registry.npm.taobao.org/he/download/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" |   resolved "https://registry.npm.taobao.org/he/download/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" | ||||||
|   integrity sha1-hK5l+n6vsWX922FWauFLrwVmTw8= |   integrity sha1-hK5l+n6vsWX922FWauFLrwVmTw8= | ||||||
| 
 | 
 | ||||||
| highlight.js@^9.16.2: | highlight.js@^9.17.1: | ||||||
|   version "9.18.1" |   version "9.18.1" | ||||||
|   resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c" |   resolved "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.1.tgz#ed21aa001fe6252bb10a3d76d47573c6539fe13c" | ||||||
|   integrity sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg== |   integrity sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg== | ||||||
| 
 | 
 | ||||||
| hmac-drbg@^1.0.0: | hmac-drbg@^1.0.0: | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "@vant/markdown-loader", |   "name": "@vant/markdown-loader", | ||||||
|   "version": "2.3.0", |   "version": "3.0.0-alpha.0", | ||||||
|   "description": "Simple and fast vue markdown loader", |   "description": "Simple and fast vue markdown loader", | ||||||
|   "main": "src/index.js", |   "main": "src/index.js", | ||||||
|   "publishConfig": { |   "publishConfig": { | ||||||
|  | |||||||
| @ -12,16 +12,11 @@ function wrapper(content) { | |||||||
|   content = escape(content); |   content = escape(content); | ||||||
| 
 | 
 | ||||||
|   return ` |   return ` | ||||||
| <template> | import { h } from 'vue'; | ||||||
|   <section v-html="content" v-once /> | 
 | ||||||
| </template> | const content = unescape(\`${content}\`);
 | ||||||
| 
 | 
 | ||||||
| <script> |  | ||||||
| export default { | export default { | ||||||
|   created() { |  | ||||||
|     this.content = unescape(\`${content}\`);
 |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   mounted() { |   mounted() { | ||||||
|     const anchors = [].slice.call(this.$el.querySelectorAll('h2, h3, h4, h5')); |     const anchors = [].slice.call(this.$el.querySelectorAll('h2, h3, h4, h5')); | ||||||
| 
 | 
 | ||||||
| @ -39,9 +34,12 @@ export default { | |||||||
|         }) |         }) | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  |   }, | ||||||
|  | 
 | ||||||
|  |   render() { | ||||||
|  |     return h('section', { innerHTML: content }); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| </script> |  | ||||||
| `;
 | `;
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -53,7 +51,7 @@ const parser = new MarkdownIt({ | |||||||
|   slugify, |   slugify, | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| module.exports = function(source) { | module.exports = function (source) { | ||||||
|   let options = loaderUtils.getOptions(this) || {}; |   let options = loaderUtils.getOptions(this) || {}; | ||||||
|   this.cacheable && this.cacheable(); |   this.cacheable && this.cacheable(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user