forked from piotrwitek/react-redux-typescript-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
styleguide.config.js
65 lines (62 loc) · 1.7 KB
/
styleguide.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const path = require('path');
const fs = require('fs');
const { createConfig } = require('webpack-blocks');
const typescript = require('@webpack-blocks/typescript');
const webpackConfig = createConfig([typescript()]);
webpackConfig.resolve.alias = { '@src': path.join(__dirname, 'src') };
module.exports = {
showUsage: false,
styleguideDir: '../docs/',
title: 'React & Redux in TypeScript - Component Typing Patterns',
ignore: ['**/*.usage.tsx'],
sections: [
{
name: 'Introduction',
content: './docs/intro.md',
},
{
name: 'Function Components',
components: () => [
'./src/components/fc-counter.tsx',
'./src/components/fc-spread-attributes.tsx',
],
},
{
name: 'Class Components',
components: () => [
'./src/components/class-counter.tsx',
'./src/components/class-counter-with-default-props.tsx',
],
},
{
name: 'Generic Components',
components: () => ['./src/components/generic-list.tsx'],
},
{
name: 'Render Props',
components: () => [
'./src/components/name-provider.tsx',
'./src/components/mouse-provider.tsx',
],
},
],
theme: {
sidebarWidth: 300,
},
propsParser: require('react-docgen-typescript').parse,
webpackConfig: webpackConfig,
updateExample: function(props, exampleFilePath) {
if (typeof props.settings.filePath === 'string') {
const {
settings: { filePath },
} = props;
delete props.settings.filePath;
props.content = fs.readFileSync(
path.resolve(exampleFilePath, '..', filePath),
{ encoding: 'utf-8' }
);
props.settings.static = true;
}
return props;
},
};