forked from jpedroschmitz/rocketdocs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
86 lines (80 loc) · 2.55 KB
/
gatsby-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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const withDefault = require(`./util/with-default`);
const path = require(`path`);
const camelCase = require('lodash.camelcase');
const upperFirst = (text) => text.charAt(0).toUpperCase() + text.slice(1);
module.exports = (options) => {
const { basePath, configPath, docsPath, yamlFilesPath, withMdx } =
withDefault(options);
return {
siteMetadata: {
basePath,
},
plugins: [
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `docs`,
path: docsPath,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `config`,
path: configPath,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `yamlFiles`,
path: yamlFilesPath,
},
},
{
resolve: `gatsby-transformer-yaml`,
options: {
typeName: ({ node, isArray }) => {
if (node.sourceInstanceName === `config`) {
return `SidebarItems`;
}
// Fallback to the existing algorithm from gatsby-transformer-yaml plugin.
// https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-transformer-yaml/src/gatsby-node.js#L22-L28
if (node.internal.type !== `File`) {
return upperFirst(camelCase(`${node.internal.type} Yaml`));
}
// Parsing algorithm: Array of Objects, where each file represents a collection.
if (isArray) {
return upperFirst(camelCase(`${node.name} Yaml`));
}
// Parsing algorithm: Single Object, where each subfolder represents a collection; each file represents one "record".
return upperFirst(camelCase(`${path.basename(node.dir)} Yaml`));
},
},
},
withMdx && {
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.mdx`, `.md`],
gatsbyRemarkPlugins: [
`gatsby-remark-autolink-headers`,
`gatsby-remark-embedder`,
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 960,
withWebp: true,
linkImagesToOriginal: false,
},
},
`gatsby-remark-responsive-iframe`,
`gatsby-remark-copy-linked-files`,
],
plugins: [`gatsby-remark-autolink-headers`, `gatsby-remark-images`],
},
},
].filter(Boolean),
};
};