diff --git a/.gitignore b/.gitignore
index 41b8349a1..5f5aad3b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@ example/dist
test/unit/coverage
packages/vant-css/build
packages/vant-css/icons
+docs/examples-dist
diff --git a/build/genExamples.js b/build/genExamples.js
index ac4eebe59..b9ecdb6fb 100644
--- a/build/genExamples.js
+++ b/build/genExamples.js
@@ -1,114 +1,18 @@
-var markdownIt = require('markdown-it');
-var markdownItContainer = require('markdown-it-container');
-var fs = require('fs');
-var path = require('path');
-var cheerio = require('cheerio');
-var chalk = require('chalk');
-var decamelize = require('decamelize');
-var striptags = require('./strip-tags');
-var navs = require('../docs/src/nav.config.js');
-navs = navs['zh-CN'];
+const path = require('path');
+const docConfig = require('../docs/src/doc.config');
+const { extractExample } = require('zan-doc/src/helper');
-var parser = markdownIt('default', {
- html: true
-});
-
-var renderVueTemplate = function(html, componentTitle) {
- var $ = cheerio.load(html, {
- decodeEntities: false,
- lowerCaseAttributeNames: false,
- lowerCaseTags: false
+function extract(watch = false) {
+ extractExample({
+ src: path.resolve(__dirname, '../docs/examples-docs'),
+ dist: path.resolve(__dirname, '../docs/examples-dist'),
+ nav: docConfig['zh-CN'].nav,
+ watch
});
+}
- var output = {
- style: $.html('style'),
- script: $.html('script'),
- 'example-block': $.html('example-block')
- };
- var result;
+extract();
- $('style').remove();
- $('script').remove();
-
- var script = '';
- if (output.script) {
- script = output.script.replace('';
- }
-
- var componentName = componentTitle.split(' ')[0];
- componentName = decamelize(componentName, '-');
- result = `${componentTitle}
` + output['example-block'] + '\n' +
- output.style + '\n' +
- script;
-
- return result;
+module.exports = function watch() {
+ extract(true);
};
-
-function convert(str) {
- str = str.replace(/()(\w{4});/gi, function($0) {
- return String.fromCharCode(parseInt(encodeURIComponent($0).replace(/(%26%23x)(\w{4})(%3B)/g, '$2'), 16));
- });
- return str;
-}
-
-parser.use(markdownItContainer, 'demo', {
- validate: function(params) {
- return params.trim().match(/^demo\s*(.*)$/);
- },
-
- render: function(tokens, idx) {
- var m = tokens[idx].info.trim().match(/^demo\s*(.*)$/);
- if (tokens[idx].nesting === 1) {
- var description = (m && m.length > 1) ? m[1] : '';
- var content = tokens[idx + 1].content;
- var html = convert(striptags.strip(content, ['script', 'style']));
-
- return `
- ${html}
- \n`;
- }
- return '';
- }
-});
-
-var docsDir = path.resolve(__dirname, '../docs');
-var components = [];
-for (var i = 0; i < navs.length; i++) {
- var navItem = navs[i];
-
- if (!navItem.showInMobile) continue;
-
- if (!navItem.groups) {
- components.push(navs[i]);
- } else {
- for (var j = 0; j < navItem.groups.length; j++) {
- components = components.concat(navItem.groups[j].list);
- }
- }
-}
-for (var i = 0; i < components.length; i++) {
- var item = components[i];
- var itemMdFile = `${docsDir}/examples-docs${item.path}.md`;
- if (!fs.existsSync(itemMdFile)) {
- continue;
- }
-
- var itemMd = fs.readFileSync(`${docsDir}/examples-docs${item.path}.md`).toString();
- var content = parser.render(itemMd);
- var result = renderVueTemplate(content, item.title);
-
- var exampleVueName = `${docsDir}/examples-dist/${item.path}.vue`;
-
- // 新建一个文件
- if (!fs.existsSync(exampleVueName)) {
- fs.closeSync(fs.openSync(exampleVueName, 'w'));
- }
- fs.writeFileSync(exampleVueName, result, {
- encoding: 'utf8'
- });
-}
-
-console.log(chalk.green('generate examples success!'));
-
diff --git a/build/webpack.config.dev.js b/build/webpack.config.dev.js
index 04ca6c82f..4294b858c 100644
--- a/build/webpack.config.dev.js
+++ b/build/webpack.config.dev.js
@@ -8,6 +8,12 @@ var ProgressBarPlugin = require('progress-bar-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
+const isProduction = process.env.NODE_ENV === 'production';
+const watchExample = require('./genExamples');
+
+if (!isProduction) {
+ watchExample();
+}
var StyleExtractPlugin;
if (process.env.NODE_ENV === 'production') {
@@ -32,7 +38,7 @@ function wrap(render) {
module.exports = {
entry: {
- 'vendor': ['vue', 'vue-router'],
+ 'vendor': ['vue', 'vue-router', 'zan-doc'],
'vant-docs': './docs/src/index.js',
'vant-examples': './docs/src/examples.js'
},
@@ -118,37 +124,23 @@ module.exports = {
},
vueMarkdown: {
use: [
- [require('markdown-it-anchor'), {
- level: 2,
- slugify: slugify,
- permalink: true,
- permalinkBefore: true
- }],
[require('markdown-it-container'), 'demo', {
validate: function(params) {
return params.trim().match(/^demo\s*(.*)$/);
},
render: function(tokens, idx) {
- var m = tokens[idx].info.trim().match(/^demo\s*(.*)$/);
if (tokens[idx].nesting === 1) {
- var description = (m && m.length > 1) ? m[1] : '';
- var content = tokens[idx + 1].content;
- var html = convert(striptags.strip(content, ['script', 'style']));
-
- return `
- ${html}
- `;
+ return `
`;
}
- return '
\n';
+ return `
\n`;
}
}]
],
preprocess: function(MarkdownIt, source) {
MarkdownIt.renderer.rules.table_open = function() {
- return '
';
+ return '';
};
- MarkdownIt.renderer.rules.fence = wrap(MarkdownIt.renderer.rules.fence);
return source;
}
}
diff --git a/docs/examples-dist/actionsheet.vue b/docs/examples-dist/actionsheet.vue
deleted file mode 100644
index 9cad0d3de..000000000
--- a/docs/examples-dist/actionsheet.vue
+++ /dev/null
@@ -1,81 +0,0 @@
-Actionsheet 行动按钮
- 弹出actionsheet
-
-
-
-
-
-
- 弹出带取消按钮的actionsheet
-
-
-
-
-
-
- 弹出带标题的actionsheet
-
- 一些内容
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/badge.vue b/docs/examples-dist/badge.vue
deleted file mode 100644
index dccaffbce..000000000
--- a/docs/examples-dist/badge.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-Badge 徽章
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/button.vue b/docs/examples-dist/button.vue
deleted file mode 100644
index 7a51f9f77..000000000
--- a/docs/examples-dist/button.vue
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/card.vue b/docs/examples-dist/card.vue
deleted file mode 100644
index 1e8a6c2af..000000000
--- a/docs/examples-dist/card.vue
+++ /dev/null
@@ -1,23 +0,0 @@
-Card 图文组件
-
-
-
-
-
-
-
商品名称是什么,两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余
- ¥ 2.00
-
-
- x 2
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/cell-swipe.vue b/docs/examples-dist/cell-swipe.vue
deleted file mode 100644
index cd91bd534..000000000
--- a/docs/examples-dist/cell-swipe.vue
+++ /dev/null
@@ -1,39 +0,0 @@
-Cell Swipe 滑动单元格
-
-
-
-
-
-
- 删除
-
-
- 选择
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/cell.vue b/docs/examples-dist/cell.vue
deleted file mode 100644
index cecd940e3..000000000
--- a/docs/examples-dist/cell.vue
+++ /dev/null
@@ -1,58 +0,0 @@
-Cell 单元格
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 起码运动馆
- 官方
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/checkbox.vue b/docs/examples-dist/checkbox.vue
deleted file mode 100644
index 89c897ed2..000000000
--- a/docs/examples-dist/checkbox.vue
+++ /dev/null
@@ -1,80 +0,0 @@
-Checkbox 复选框
-
- 复选框1
-
-
-
-
-
-
- 复选框2
-
-
-
-
-
-
-
- 复选框{{item}}
-
-
-
-
-
-
-
-
- 复选框{{item}}
-
-
-
-
-
-
-
-
-
- 复选框{{item}}
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/datetime-picker.vue b/docs/examples-dist/datetime-picker.vue
deleted file mode 100644
index a3eba9767..000000000
--- a/docs/examples-dist/datetime-picker.vue
+++ /dev/null
@@ -1,42 +0,0 @@
-Datetime Picker 时间选择
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/dialog.vue b/docs/examples-dist/dialog.vue
deleted file mode 100644
index 52a14caaa..000000000
--- a/docs/examples-dist/dialog.vue
+++ /dev/null
@@ -1,60 +0,0 @@
-Dialog 弹出框
- alert
-无标题alert
-
-
-
-
- confirm
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/field.vue b/docs/examples-dist/field.vue
deleted file mode 100644
index 1241f24af..000000000
--- a/docs/examples-dist/field.vue
+++ /dev/null
@@ -1,52 +0,0 @@
-Field 输入框
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/icon.vue b/docs/examples-dist/icon.vue
deleted file mode 100644
index 40620f0e0..000000000
--- a/docs/examples-dist/icon.vue
+++ /dev/null
@@ -1,290 +0,0 @@
-Icon 图标
-
-
-
-
-
-
- qr-invalid
-
-
-
- qr
-
-
-
- exchange
-
-
-
- close
-
-
-
- location
-
-
-
- upgrade
-
-
-
- check
-
-
-
- checked
-
-
-
- like-o
-
-
-
- like
-
-
-
- chat
-
-
-
- shop
-
-
-
- photograph
-
-
-
- add
-
-
-
- add2
-
-
-
- photo
-
-
-
- edit
-
-
-
- passed
-
-
-
- cart
-
-
-
- arrow
-
-
-
- gift
-
-
-
- search
-
-
-
- clear
-
-
-
- success
-
-
-
- fail
-
-
-
- contact
-
-
-
- wechat
-
-
-
- alipay
-
-
-
- password-view
-
-
-
- wap-nav
-
-
-
- password-not-view
-
-
-
- wap-home
-
-
-
- ecard-pay
-
-
-
- balance-pay
-
-
-
- peer-pay
-
-
-
- credit-pay
-
-
-
- debit-pay
-
-
-
- other-pay
-
-
-
- cart
-
-
-
- browsing-history
-
-
-
- goods-collect
-
-
-
- shop-collect
-
-
-
- receive-gift
-
-
-
- send-gift
-
-
-
- setting
-
-
-
- points
-
-
-
- coupon
-
-
-
- free-postage
-
-
-
- discount
-
-
-
- birthday-privilege
-
-
-
- member-day-privilege
-
-
-
- balance-details
-
-
-
- cash-back-record
-
-
-
- points-mall
-
-
-
- exchange-record
-
-
-
- pending-payment
-
-
-
- pending-orders
-
-
-
- pending-deliver
-
-
-
- logistics
-
-
-
- pending-evaluate
-
-
-
- cash-on-deliver
-
-
-
- gift-card-pay
-
-
-
- underway
-
-
-
- point-gift
-
-
-
- after-sale
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/image-preview.vue b/docs/examples-dist/image-preview.vue
deleted file mode 100644
index 28572f8a9..000000000
--- a/docs/examples-dist/image-preview.vue
+++ /dev/null
@@ -1,34 +0,0 @@
-ImagePreview 图片预览
- 预览图片
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/layout.vue b/docs/examples-dist/layout.vue
deleted file mode 100644
index 99f74fa79..000000000
--- a/docs/examples-dist/layout.vue
+++ /dev/null
@@ -1,71 +0,0 @@
-Layout 布局
-
-
- span: 8
-
-
- span: 8
-
-
- span: 8
-
-
-
-
- span: 4
-
-
- offset: 4, span: 10
-
-
-
-
- offset: 12, span: 12
-
-
-
-
-
-
- span: 8
-
-
- span: 8
-
-
- span: 8
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/lazyload.vue b/docs/examples-dist/lazyload.vue
deleted file mode 100644
index c8d1579c2..000000000
--- a/docs/examples-dist/lazyload.vue
+++ /dev/null
@@ -1,78 +0,0 @@
-Lazyload 图片懒加载
-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/loading.vue b/docs/examples-dist/loading.vue
deleted file mode 100644
index 15f88434f..000000000
--- a/docs/examples-dist/loading.vue
+++ /dev/null
@@ -1,38 +0,0 @@
-Loading 加载
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/panel.vue b/docs/examples-dist/panel.vue
deleted file mode 100644
index c4a86f503..000000000
--- a/docs/examples-dist/panel.vue
+++ /dev/null
@@ -1,65 +0,0 @@
-Panel 面板
-
-
- panel内容
-
-
-
-
-
-
-
-
商品名称是什么,两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余两行显示状态如效果图,多余多余多余
- ¥ 2.00
-
-
-
商品sku
- x 2
-
-
-
-
- 合计:¥ 1999.90
-
-
- 按钮一
- 按钮二
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/picker.vue b/docs/examples-dist/picker.vue
deleted file mode 100644
index c530067af..000000000
--- a/docs/examples-dist/picker.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-Picker 选择器
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/popup.vue b/docs/examples-dist/popup.vue
deleted file mode 100644
index 1db6b6907..000000000
--- a/docs/examples-dist/popup.vue
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/progress.vue b/docs/examples-dist/progress.vue
deleted file mode 100644
index bdc489ae2..000000000
--- a/docs/examples-dist/progress.vue
+++ /dev/null
@@ -1,46 +0,0 @@
-Progress 进度条
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/quantity.vue b/docs/examples-dist/quantity.vue
deleted file mode 100644
index e2d0ddb94..000000000
--- a/docs/examples-dist/quantity.vue
+++ /dev/null
@@ -1,36 +0,0 @@
-Quantity 数量选择
-
-当前值:{{ quantity1 }}
-
-
-
-
-
-
-当前值:{{ quantity2 || 9 }}
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/radio.vue b/docs/examples-dist/radio.vue
deleted file mode 100644
index 978319c8a..000000000
--- a/docs/examples-dist/radio.vue
+++ /dev/null
@@ -1,63 +0,0 @@
-Radio 单选框
-
- 单选框1
- 单选框2
-
-
-
-
-
-
- 未选中禁用
- 选中且禁用
-
-
-
-
-
-
-
- 单选框1
- 单选框2
-
-
-
-
-
-
-
-
- 单选框1
- 单选框2
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/search.vue b/docs/examples-dist/search.vue
deleted file mode 100644
index 0a05cfb6e..000000000
--- a/docs/examples-dist/search.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-Search 搜索
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/steps.vue b/docs/examples-dist/steps.vue
deleted file mode 100644
index 735c128fb..000000000
--- a/docs/examples-dist/steps.vue
+++ /dev/null
@@ -1,76 +0,0 @@
-Steps 步骤条
-
- 买家下单
- 商家接单
- 买家提货
- 交易完成
-
-
-下一步
-
-
-
-
-
- 买家下单
- 商家接单
- 买家提货
- 交易完成
-
-
-
-
-
- 【城市】最新的物流状态之类的表述哈哈哈哈
- 2016-07-12 12:12:12
-
-
- 【城市】已经过了的物流状态我是折行我是折行我是折行联系电话:158630099999
- 2016-07-12 12:12:12
-
-
- 未发货
- 2016-07-12 12:12:12
-
-
-
-
-
-
- 流程
- 买家下单
- 商家接单
- 买家提货
- 交易完成
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/swipe.vue b/docs/examples-dist/swipe.vue
deleted file mode 100644
index 338fdf8ba..000000000
--- a/docs/examples-dist/swipe.vue
+++ /dev/null
@@ -1,57 +0,0 @@
-Swipe 轮播
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/switch.vue b/docs/examples-dist/switch.vue
deleted file mode 100644
index 4026260c3..000000000
--- a/docs/examples-dist/switch.vue
+++ /dev/null
@@ -1,89 +0,0 @@
-Switch 开关
-
-
-
- {{ switchState1 ? ' 打开' : '关闭' }}
-
-
-
- {{ switchState2 ? ' 打开' : '关闭' }}
-
-
-
-
-
-
-
-
-
-
-
- 打开
-
-
-
- 关闭
-
-
-
-
-
-
-
-
-
- 打开
-
-
-
- 关闭
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/tab.vue b/docs/examples-dist/tab.vue
deleted file mode 100644
index fa8534e5d..000000000
--- a/docs/examples-dist/tab.vue
+++ /dev/null
@@ -1,136 +0,0 @@
-Tab 标签
-
- 内容一
- 内容二
- 内容三
- 内容四
-
-
-
-
- 内容一
- 内容二
- 内容三
- 内容四
-
-
-
-
- 内容一
- 内容二
- 内容三
-
-
-
-
- 内容一
- 内容二
- 内容三
- 内容四
- 内容五
- 内容六
- 内容七
- 内容八
-
-
-
-
- 内容一
- 内容二
- 内容三
- 内容四
-
-
-
-
-
-
- 内容一
- 内容二
- 内容三
- 内容四
-
-
-
-
- 内容一
- 内容二
- 内容三
- 内容四
-
-
-
-
-
-
- 内容一
- 内容二
- 内容三
- 内容四
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/tag.vue b/docs/examples-dist/tag.vue
deleted file mode 100644
index 407388999..000000000
--- a/docs/examples-dist/tag.vue
+++ /dev/null
@@ -1,40 +0,0 @@
-Tag 标记
-
- 返现
-
-
- 返现
- 四字标签
- 一
-
-
-
-
- 返现
- 返现
-
-
- 返现
- 返现
-
-
- 返现
- 返现
-
-
- 返现
- 返现
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/toast.vue b/docs/examples-dist/toast.vue
deleted file mode 100644
index 918f64275..000000000
--- a/docs/examples-dist/toast.vue
+++ /dev/null
@@ -1,86 +0,0 @@
-Toast 轻提示
- 普通文字提示
-加载Toast
-成功
-失败
-背景不能点击
-倒数5秒
-
-
-
-
- 打开
-关闭
-
-
-
-
- 打开
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/uploader.vue b/docs/examples-dist/uploader.vue
deleted file mode 100644
index ddeb29917..000000000
--- a/docs/examples-dist/uploader.vue
+++ /dev/null
@@ -1,25 +0,0 @@
-Uploader 图片上传
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-dist/waterfall.vue b/docs/examples-dist/waterfall.vue
deleted file mode 100644
index 3a9951243..000000000
--- a/docs/examples-dist/waterfall.vue
+++ /dev/null
@@ -1,73 +0,0 @@
-Waterfall 瀑布流
- 当即将滚动到元素底部时,会自动加载更多
-
-
-
-
-
\ No newline at end of file
diff --git a/docs/examples-docs/quickstart.md b/docs/examples-docs/quickstart.md
index 3636ce4f2..c0b202cc7 100644
--- a/docs/examples-docs/quickstart.md
+++ b/docs/examples-docs/quickstart.md
@@ -1,7 +1,8 @@
## Vant
-一套基于`Vue.js 2.0`的Mobile组件库
-
A Vue.js 2.0 Mobile UI
+一套基于`Vue.js 2.0`的 Mobile 组件库
+
+[查看业务组件库 Captain-UI](https://www.youzanyun.com/zanui/captain/component/quickstart)
### 安装
diff --git a/docs/src/ExamplesDocsApp.vue b/docs/src/ExamplesDocsApp.vue
index 19ad99e08..c8753bf7f 100644
--- a/docs/src/ExamplesDocsApp.vue
+++ b/docs/src/ExamplesDocsApp.vue
@@ -1,40 +1,30 @@
diff --git a/docs/src/components/demo-list.vue b/docs/src/components/demo-list.vue
index 301202bb9..87d9ecdd5 100644
--- a/docs/src/components/demo-list.vue
+++ b/docs/src/components/demo-list.vue
@@ -13,7 +13,7 @@
-
-
diff --git a/docs/src/components/page-footer.vue b/docs/src/components/page-footer.vue
deleted file mode 100644
index d840c518b..000000000
--- a/docs/src/components/page-footer.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
diff --git a/docs/src/components/page-header.vue b/docs/src/components/page-header.vue
deleted file mode 100644
index f0cf42a77..000000000
--- a/docs/src/components/page-header.vue
+++ /dev/null
@@ -1,146 +0,0 @@
-
-
-
-
-
-
-
diff --git a/docs/src/components/side-nav.vue b/docs/src/components/side-nav.vue
deleted file mode 100644
index 98298acf4..000000000
--- a/docs/src/components/side-nav.vue
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js
new file mode 100644
index 000000000..b58bf3a99
--- /dev/null
+++ b/docs/src/doc.config.js
@@ -0,0 +1,181 @@
+/* eslint-disable */
+module.exports = {
+ "zh-CN": {
+ header: {
+ '首页': 'https://www.youzanyun.com/zanui',
+ 'PC端': 'https://www.youzanyun.com/zanui/react',
+ '移动端': 'https://www.youzanyun.com/zanui/vue',
+ '微信小程序': 'https://github.com/youzan/zanui-weapp'
+ },
+ footer: {
+ copyright: `2012-${(new Date()).getFullYear()} © youzanyun.com - 浙公网安备 33010602004354号 增值电信业务经营许可证:浙B2-20140331 - 浙ICP备13037466号`,
+ nav: {
+ '有赞官网': 'https://www.youzan.com/',
+ '有赞云': 'http://www.youzanyun.com/zanui',
+ '加入我们': 'https://job.youzan.com/'
+ }
+ },
+ nav: [
+ {
+ "name": "开发指南",
+ "groups": [
+ {
+ "list": [
+ {
+ "path": "/quickstart",
+ "title": "快速上手",
+ noExample: true
+ },
+ {
+ "path": "/changelog",
+ "title": "更新日志",
+ noExample: true
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "name": "Vant组件",
+ "showInMobile": true,
+ "groups": [
+ {
+ "groupName": "基础组件",
+ "list": [
+ {
+ "path": "/layout",
+ "title": "Layout 布局"
+ },
+ {
+ "path": "/button",
+ "title": "Button 按钮"
+ },
+ {
+ "path": "/icon",
+ "title": "Icon 图标"
+ },
+ {
+ "path": "/cell",
+ "title": "Cell 单元格"
+ },
+ {
+ "path": "/cell-swipe",
+ "title": "Cell Swipe 滑动单元格"
+ },
+ {
+ "path": "/progress",
+ "title": "Progress 进度条"
+ },
+ {
+ "path": "/card",
+ "title": "Card 图文组件"
+ },
+ {
+ "path": "/panel",
+ "title": "Panel 面板"
+ },
+ {
+ "path": "/loading",
+ "title": "Loading 加载"
+ },
+ {
+ "path": "/steps",
+ "title": "Steps 步骤条"
+ },
+ {
+ "path": "/tag",
+ "title": "Tag 标记"
+ },
+ {
+ "path": "/badge",
+ "title": "Badge 徽章"
+ },
+ {
+ "path": "/tab",
+ "title": "Tab 标签"
+ },
+ {
+ "path": "/popup",
+ "title": "Popup 弹出菜单"
+ },
+ {
+ "path": "/swipe",
+ "title": "Swipe 轮播"
+ },
+ {
+ "path": "/search",
+ "title": "Search 搜索"
+ },
+ {
+ "path": "/quantity",
+ "title": "Quantity 数量选择"
+ },
+ {
+ "path": "/waterfall",
+ "title": "Waterfall 瀑布流"
+ },
+ {
+ "path": "/image-preview",
+ "title": "ImagePreview 图片预览"
+ },
+ {
+ "path": "/lazyload",
+ "title": "Lazyload 图片懒加载"
+ }
+ ]
+ },
+ {
+ "groupName": "表单",
+ "list": [
+ {
+ "path": "/switch",
+ "title": "Switch 开关"
+ },
+ {
+ "path": "/field",
+ "title": "Field 输入框"
+ },
+ {
+ "path": "/radio",
+ "title": "Radio 单选框"
+ },
+ {
+ "path": "/checkbox",
+ "title": "Checkbox 复选框"
+ },
+ {
+ "path": "/uploader",
+ "title": "Uploader 图片上传"
+ }
+ ]
+ },
+ {
+ "groupName": "操作反馈",
+ "list": [
+ {
+ "path": "/actionsheet",
+ "title": "Actionsheet 行动按钮"
+ },
+ {
+ "path": "/toast",
+ "title": "Toast 轻提示"
+ },
+ {
+ "path": "/picker",
+ "title": "Picker 选择器"
+ },
+ {
+ "path": "/datetime-picker",
+ "title": "Datetime Picker 时间选择"
+ },
+ {
+ "path": "/dialog",
+ "title": "Dialog 弹出框"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/docs/src/examples.js b/docs/src/examples.js
index 3018f60f2..d6d0c5d6d 100644
--- a/docs/src/examples.js
+++ b/docs/src/examples.js
@@ -1,21 +1,21 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './ExamplesApp';
-import navConfig from './nav.config.js';
import routes from './router.config';
import ZanUI from 'src/index';
-
+import ZanDoc from 'zan-doc';
import 'packages/vant-css/src/index.css';
import DemoList from './components/demo-list.vue';
Vue.use(ZanUI);
+Vue.use(ZanDoc);
Vue.use(ZanUI.Lazyload, {
lazyComponent: true
});
Vue.use(VueRouter);
-const routesConfig = routes(navConfig, true);
+const routesConfig = routes(true);
routesConfig.push({
path: '/',
component: DemoList.default || DemoList
diff --git a/docs/src/index.js b/docs/src/index.js
index 14d173937..2f7c3b729 100644
--- a/docs/src/index.js
+++ b/docs/src/index.js
@@ -1,10 +1,11 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './ExamplesDocsApp';
-import navConfig from './nav.config.js';
import routes from './router.config';
import ZanUI from 'src/index.js';
+import ZanDoc from 'zan-doc';
import packageJson from '../../package.json';
+import DemoBlock from './components/demo-block';
const global = {
version: packageJson.version
@@ -22,11 +23,13 @@ function isMobile() {
Vue.use(VueRouter);
Vue.use(ZanUI);
+Vue.use(ZanDoc);
Vue.use(ZanUI.Lazyload, {
lazyComponent: true
});
+Vue.component('demo-block', DemoBlock);
-const routesConfig = routes(navConfig);
+const routesConfig = routes();
routesConfig.push({
path: '/',
redirect: '/component/quickstart'
diff --git a/docs/src/nav.config.js b/docs/src/nav.config.js
deleted file mode 100644
index 9ea040ac0..000000000
--- a/docs/src/nav.config.js
+++ /dev/null
@@ -1,163 +0,0 @@
-/* eslint-disable */
-module.exports = {
- "zh-CN": [
- {
- "name": "开发指南",
- "groups": [
- {
- "list": [
- {
- "path": "/quickstart",
- "title": "快速上手"
- },
- {
- "path": "/changelog",
- "title": "更新日志"
- }
- ]
- }
- ]
- },
- {
- "name": "Vant组件",
- "showInMobile": true,
- "groups": [
- {
- "groupName": "基础组件",
- "list": [
- {
- "path": "/layout",
- "title": "Layout 布局"
- },
- {
- "path": "/button",
- "title": "Button 按钮"
- },
- {
- "path": "/icon",
- "title": "Icon 图标"
- },
- {
- "path": "/cell",
- "title": "Cell 单元格"
- },
- {
- "path": "/cell-swipe",
- "title": "Cell Swipe 滑动单元格"
- },
- {
- "path": "/progress",
- "title": "Progress 进度条"
- },
- {
- "path": "/card",
- "title": "Card 图文组件"
- },
- {
- "path": "/panel",
- "title": "Panel 面板"
- },
- {
- "path": "/loading",
- "title": "Loading 加载"
- },
- {
- "path": "/steps",
- "title": "Steps 步骤条"
- },
- {
- "path": "/tag",
- "title": "Tag 标记"
- },
- {
- "path": "/badge",
- "title": "Badge 徽章"
- },
- {
- "path": "/tab",
- "title": "Tab 标签"
- },
- {
- "path": "/popup",
- "title": "Popup 弹出菜单"
- },
- {
- "path": "/swipe",
- "title": "Swipe 轮播"
- },
- {
- "path": "/search",
- "title": "Search 搜索"
- },
- {
- "path": "/quantity",
- "title": "Quantity 数量选择"
- },
- {
- "path": "/waterfall",
- "title": "Waterfall 瀑布流"
- },
- {
- "path": "/image-preview",
- "title": "ImagePreview 图片预览"
- },
- {
- "path": "/lazyload",
- "title": "Lazyload 图片懒加载"
- }
- ]
- },
- {
- "groupName": "表单",
- "list": [
- {
- "path": "/switch",
- "title": "Switch 开关"
- },
- {
- "path": "/field",
- "title": "Field 输入框"
- },
- {
- "path": "/radio",
- "title": "Radio 单选框"
- },
- {
- "path": "/checkbox",
- "title": "Checkbox 复选框"
- },
- {
- "path": "/uploader",
- "title": "Uploader 图片上传"
- }
- ]
- },
- {
- "groupName": "操作反馈",
- "list": [
- {
- "path": "/actionsheet",
- "title": "Actionsheet 行动按钮"
- },
- {
- "path": "/toast",
- "title": "Toast 轻提示"
- },
- {
- "path": "/picker",
- "title": "Picker 选择器"
- },
- {
- "path": "/datetime-picker",
- "title": "Datetime Picker 时间选择"
- },
- {
- "path": "/dialog",
- "title": "Dialog 弹出框"
- }
- ]
- }
- ]
- }
- ]
-}
diff --git a/docs/src/router.config.js b/docs/src/router.config.js
index 77c2502e9..19d7ad0a3 100644
--- a/docs/src/router.config.js
+++ b/docs/src/router.config.js
@@ -1,6 +1,7 @@
-const registerRoute = (navConfig, isExample) => {
+const navs = require('./doc.config')['zh-CN'].nav;
+
+const registerRoute = (isExample) => {
let route = [];
- let navs = navConfig['zh-CN'];
navs.forEach(nav => {
if (isExample && !nav.showInMobile) {
return;
diff --git a/package.json b/package.json
index 0f388faa4..059fade63 100644
--- a/package.json
+++ b/package.json
@@ -134,6 +134,7 @@
"webpack-dev-server": "^1.16.3",
"webpack-merge": "^2.0.0",
"webpack-node-externals": "^1.5.4",
- "webpack-vendor-chunk-plugin": "^1.0.0"
+ "webpack-vendor-chunk-plugin": "^1.0.0",
+ "zan-doc": "^0.0.9"
}
}
diff --git a/yarn.lock b/yarn.lock
index a12b0deb4..ef2853f18 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1116,19 +1116,7 @@ change-case@3.0.x:
upper-case "^1.1.1"
upper-case-first "^1.1.0"
-cheerio@^0.20.0:
- version "0.20.0"
- resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.20.0.tgz#5c710f2bab95653272842ba01c6ea61b3545ec35"
- dependencies:
- css-select "~1.2.0"
- dom-serializer "~0.1.0"
- entities "~1.1.1"
- htmlparser2 "~3.8.1"
- lodash "^4.1.0"
- optionalDependencies:
- jsdom "^7.0.2"
-
-cheerio@^0.22.0:
+cheerio@0.22.0, cheerio@^0.22.0:
version "0.22.0"
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e"
dependencies:
@@ -1149,6 +1137,18 @@ cheerio@^0.22.0:
lodash.reject "^4.4.0"
lodash.some "^4.4.0"
+cheerio@^0.20.0:
+ version "0.20.0"
+ resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.20.0.tgz#5c710f2bab95653272842ba01c6ea61b3545ec35"
+ dependencies:
+ css-select "~1.2.0"
+ dom-serializer "~0.1.0"
+ entities "~1.1.1"
+ htmlparser2 "~3.8.1"
+ lodash "^4.1.0"
+ optionalDependencies:
+ jsdom "^7.0.2"
+
chokidar@^1.4.1, chokidar@^1.4.3, chokidar@^1.6.1:
version "1.6.1"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2"
@@ -4014,6 +4014,12 @@ liftoff@^2.1.0:
rechoir "^0.6.2"
resolve "^1.1.7"
+linkify-it@^2.0.0:
+ version "2.0.3"
+ resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.0.3.tgz#d94a4648f9b1c179d64fa97291268bdb6ce9434f"
+ dependencies:
+ uc.micro "^1.0.1"
+
linkify-it@~1.2.2:
version "1.2.4"
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-1.2.4.tgz#0773526c317c8fd13bd534ee1d180ff88abf881a"
@@ -4384,11 +4390,21 @@ markdown-it@^6.0.5, markdown-it@^6.1.1:
mdurl "~1.0.1"
uc.micro "^1.0.1"
+markdown-it@^8.3.1:
+ version "8.3.1"
+ resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-8.3.1.tgz#2f4b622948ccdc193d66f3ca2d43125ac4ac7323"
+ dependencies:
+ argparse "^1.0.7"
+ entities "~1.1.1"
+ linkify-it "^2.0.0"
+ mdurl "^1.0.1"
+ uc.micro "^1.0.3"
+
math-expression-evaluator@^1.2.14:
version "1.2.16"
resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.16.tgz#b357fa1ca9faefb8e48d10c14ef2bcb2d9f0a7c9"
-mdurl@~1.0.1:
+mdurl@^1.0.1, mdurl@~1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
@@ -4626,6 +4642,10 @@ node-pre-gyp@^0.6.29:
tar "^2.2.1"
tar-pack "^3.4.0"
+node-watch@^0.5.5:
+ version "0.5.5"
+ resolved "https://registry.yarnpkg.com/node-watch/-/node-watch-0.5.5.tgz#34865ba8bc6861ab086acdcc3403e40ed55c3274"
+
nomnomnomnom@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/nomnomnomnom/-/nomnomnomnom-2.0.1.tgz#b2239f031c8d04da67e32836e1e3199e12f7a8e2"
@@ -6707,7 +6727,7 @@ typedarray@^0.0.6, typedarray@~0.0.5:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
-uc.micro@^1.0.1:
+uc.micro@^1.0.1, uc.micro@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.3.tgz#7ed50d5e0f9a9fb0a573379259f2a77458d50192"
@@ -7287,3 +7307,13 @@ yauzl@2.4.1:
yeast@0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
+
+zan-doc@0.0.9:
+ version "0.0.9"
+ resolved "https://registry.yarnpkg.com/zan-doc/-/zan-doc-0.0.9.tgz#fcbd2ae743ec2b05594c124c8632345391f8a680"
+ dependencies:
+ cheerio "0.22.0"
+ decamelize "^1.2.0"
+ markdown-it "^8.3.1"
+ markdown-it-container "^2.0.0"
+ node-watch "^0.5.5"