├── test └── index.js ├── .gitignore ├── .travis.yml ├── template.html ├── index.js ├── README.md └── package.json /test/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .idea/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: stable 3 | 4 | branches: 5 | only: 6 | - master -------------------------------------------------------------------------------- /template.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'), 2 | path = require('path'), 3 | _ = require('underscore'); 4 | 5 | var filePath = path.join(__dirname, 'template.html'); 6 | 7 | function echartsMaps(args, content) { 8 | var template = fs.readFileSync(filePath).toString(), 9 | options = {}; 10 | 11 | if (content.length) { 12 | var options = content; 13 | } 14 | 15 | return _.template(template)({ 16 | id: 'echarts' + ((Math.random() * 9999) | 0), 17 | option: options, 18 | height: args[0] || 400, 19 | width: args[1] || '85%' 20 | }); 21 | } 22 | 23 | hexo.extend.tag.register('echarts', echartsMaps, { 24 | async: true, 25 | ends: true 26 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hexo-tag-echarts 2 | 3 | [![npm](https://img.shields.io/npm/v/hexo-tag-echarts3.svg)]() [![Travis](https://img.shields.io/travis/quentin-chen/hexo-tag-echarts3.svg)]() [![David](https://img.shields.io/david/quentin-chen/hexo-tag-echarts3.svg)]() [![David](https://img.shields.io/david/dev/quentin-chen/hexo-tag-echarts3.svg)]() 4 | 5 | Insert [Echarts](http://echarts.baidu.com) in Hexo by using tags. 6 | 7 | ## Install 8 | 9 | ```bash 10 | $ npm install hexo-tag-echarts --save 11 | ``` 12 | 13 | ## Usage 14 | 15 | ``` 16 | {% echarts 400 '85%' %} 17 | \\TODO echarts option goes here 18 | {% endecharts %} 19 | ``` 20 | 21 | For more details, visit [Demo](http://kchen.cc/2016/11/05/echarts-in-hexo/) here. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hexo-tag-echarts3", 3 | "version": "1.1.2", 4 | "description": "A simple plugin for inserting ECharts 3 by using tags in Hexo.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "make test" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/quentin-chen/hexo-tag-echarts3.git" 12 | }, 13 | "keywords": [ 14 | "hexo", 15 | "tag", 16 | "echarts" 17 | ], 18 | "author": "Quentin Chen", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/quentin-chen/hexo-tag-echarts3/issues" 22 | }, 23 | "homepage": "https://github.com/quentin-chen/hexo-tag-echarts3#readme", 24 | "dependencies": { 25 | "underscore": "^1.8.3" 26 | } 27 | } 28 | --------------------------------------------------------------------------------