Skip to content
This repository was archived by the owner on Apr 1, 2019. It is now read-only.

Commit 492cf43

Browse files
committed
add dynamically doc loading
1 parent 77e854f commit 492cf43

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

template/docs/UseCase2.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ You can add more examples!
22

33
<{{ name }} text="Hello World!" style="background-color: pink;"></{{ name }}>
44

5-
* Remember to update styleguide.config.js also
5+
* Remember that you can also update styleguide.config.js to use your own
6+
own doc definitions

template/styleguide.config.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
const loaders = require('vue-webpack-loaders');
2+
const glob = require('glob').sync;
3+
const basename = require('path').basename;
4+
5+
function getDocSections() {
6+
b = p => basename(p, '.md');
7+
return glob('docs/*.md')
8+
.filter(path => b(path)!=='Introduction')
9+
.map(path => ({
10+
name: b(path),
11+
content: path
12+
}));
13+
}
14+
215
/**
316
* More info about this styleguide configuration in
417
* vue-styleguidist/vue-styleguidist github repository
@@ -7,22 +20,11 @@ module.exports = {
720
sections: [
821
{
922
/* The component itself */
10-
name: '{{ name }}',
23+
name: 'test-cmp1',
1124
content: 'docs/Introduction.md',
1225
components: 'src/**/*.vue',
1326
// ignore: ['src/ignored-component/ignored-component.vue'],
14-
sections: [
15-
/* One item for each demo or example of the component */
16-
{
17-
name: 'Use Case 1',
18-
content: 'docs/UseCase1.md'
19-
},
20-
/* One item for each demo or example of the component */
21-
{
22-
name: 'Use Case 2',
23-
content: 'docs/UseCase2.md'
24-
}
25-
]
27+
sections: getDocSections()
2628
},
2729
],
2830
webpackConfig: {

0 commit comments

Comments
 (0)