-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgatsby-config.fix.js
More file actions
125 lines (116 loc) · 3.27 KB
/
gatsby-config.fix.js
File metadata and controls
125 lines (116 loc) · 3.27 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// need to fix https://github.com/doczjs/docz/issues/1629
const path = require('path')
const { getDoczConfig } = require('./lib/utils/parseConfig')
const getRemarkPlugins = () => {
let plugins = []
try {
plugins = [
require('remark-hint'),
require('remark-emoji'),
require('remark-math'),
[require('remark-frontmatter'), { type: 'yaml', marker: '-' }],
require('remark-docz'),
]
} catch (err) {
plugins = []
}
return plugins
}
const getRehypePlugins = () => {
let plugins = []
try {
plugins = [
require('rehype-katex'),
require('rehype-docz'),
require('rehype-slug'),
]
} catch (err) {
plugins = []
}
return plugins
}
const getGatsbyRemarkPlugins = () => {
return []
}
module.exports = opts => {
const config = getDoczConfig(opts)
const mdPlugins = getRemarkPlugins()
const hastPlugins = getRehypePlugins()
const gatsbyRemarkPlugins = getGatsbyRemarkPlugins()
return {
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
ignore: [
`${config.paths.docz}/**/*`,
`${config.paths.root}/.git/**/*`,
// gatsby cache
`${config.paths.root}/.cache/**/*`,
// static assets with gatsby site setup
`${config.paths.root}/public/**/*`,
// ignore node_modules unless user explicitly asks for them to be included
config.src.indexOf('node_modules') === -1
? `${config.paths.root}/node_modules/**/*`
: `${config.paths.root}/node_modules/.cache/**/*`,
],
path: path.resolve(
config.paths.root,
config.gatsbyRoot !== null ? config.gatsbyRoot : config.src
),
},
},
{
resolve: 'gatsby-plugin-mdx',
options: {
lessBabel: true,
extensions: config.mdxExtensions,
remarkPlugins:
config && config.mdPlugins
? config.mdPlugins.concat(mdPlugins)
: mdPlugins,
rehypePlugins:
config && config.hastPlugins
? config.hastPlugins.concat(hastPlugins)
: hastPlugins,
gatsbyRemarkPlugins:
config && config.gatsbyRemarkPlugins
? config.gatsbyRemarkPlugins.concat(gatsbyRemarkPlugins)
: gatsbyRemarkPlugins,
defaultLayouts: {
default: path.join(__dirname, 'src/base/Layout.js'),
},
},
},
{
resolve: 'gatsby-plugin-catch-links',
},
{
resolve: 'gatsby-plugin-react-helmet-async',
},
{
resolve: 'gatsby-plugin-root-import',
},
{
resolve: 'gatsby-plugin-emotion',
},
{
resolve: 'gatsby-plugin-alias-imports',
options: {
alias: {
'~components': path.resolve(__dirname, 'src/components'),
'~styles': path.resolve(__dirname, 'src/styles'),
'~theme': path.resolve(__dirname, 'src/theme'),
'~utils': path.resolve(__dirname, 'src/utils'),
},
},
},
{
resolve: 'gatsby-plugin-compile-es6-packages',
options: {
modules: ['docz', 'docz-core', 'gatsby-theme-docz'],
},
},
],
}
}