[Doc] add build-in style document (#633)

This commit is contained in:
neverland
2018-02-09 16:38:44 +08:00
committed by GitHub
parent 6ac8a8d2c0
commit 6f52b59d50
15 changed files with 216 additions and 33 deletions

View File

@@ -6,7 +6,6 @@
class="van-doc-nav-bar"
:title="title"
left-arrow
:left-text="$t('back')"
@click-left="onBack"
/>
<router-view />
@@ -14,13 +13,11 @@
</template>
<script>
import { camelize } from 'packages/utils';
export default {
computed: {
title() {
const name = this.$route.name;
return name ? camelize(name.split('/').pop()) : '';
const { name } = this.$route.meta;
return name ? name.replace(/-/g, '') : '';
}
},

View File

@@ -37,6 +37,10 @@ module.exports = {
title: '更新日志',
noExample: true
},
{
path: '/built-in-style',
title: '内置样式'
},
{
path: '/theme',
title: '定制主题',
@@ -319,6 +323,10 @@ module.exports = {
title: 'Changelog',
noExample: true
},
{
path: '/built-in-style',
title: 'Built-in style'
},
{
path: '/theme',
title: 'Custom Theme',

View File

@@ -1,7 +1,7 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './WapApp';
import routes from './router.config';
import routes from './router';
import Vant, { Lazyload } from 'packages';
import VantDoc from 'vant-doc';
import 'packages/vant-css/src/index.css';

View File

@@ -1,7 +1,7 @@
import Vue from 'vue';
import VueRouter from 'vue-router';
import App from './DocsApp';
import routes from './router.config';
import routes from './router';
import VantDoc from 'vant-doc';
import isMobile from './utils/is-mobile';
import './components/nprogress.css';

View File

@@ -28,22 +28,20 @@ const registerRoute = (isExample) => {
const navs = docConfig[lang].nav || [];
navs.forEach(nav => {
if (isExample && !nav.showInMobile) {
return;
}
if (nav.groups) {
nav.groups.forEach(group => {
group.list.forEach(page => addRoute(page, lang));
});
} else if (nav.children) {
nav.children.forEach(page => addRoute(page, lang));
} else {
addRoute(nav, lang);
}
});
function addRoute(page, lang) {
if (isExample && page.noExample) {
return;
}
const { path } = page;
if (path) {
const name = lang + '/' + path.replace('/', '');
@@ -59,7 +57,10 @@ const registerRoute = (isExample) => {
name,
component,
path: `/${lang}/component${path}`,
meta: { lang }
meta: {
lang,
name: page.title
}
});
}
}