forked from keystonejs/keystone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
121 lines (115 loc) · 3.62 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
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
const { getPackages } = require('@manypkg/get-packages');
const fs = require('fs');
const path = require('path');
async function getPackagePlugins() {
const rootDir = path.resolve(__dirname, '..');
const docSections = fs.readdirSync(`${rootDir}/docs/`).filter(dir => {
const fullDir = path.join(`${rootDir}/docs/`, dir);
return fs.existsSync(fullDir) && fs.lstatSync(fullDir).isDirectory();
});
const { packages } = await getPackages(rootDir);
return [
...docSections.map(name => ({
resolve: 'gatsby-source-filesystem',
options: { name, path: `${rootDir}/docs/${name}/` },
})),
...packages
.filter(({ packageJson }) => !packageJson.private)
.filter(({ dir }) => fs.existsSync(dir))
.filter(
({ dir }) =>
!dir.includes('arch') && !dir.includes('packages-next') && !dir.includes('design-system')
)
.map(({ dir, packageJson }) => ({
resolve: 'gatsby-source-filesystem',
options: {
// This `name` will show up as `sourceInstanceName` on a node's "parent"
// See `gatsby-node.js` for where it's used.
name: packageJson.name,
path: `${dir}`,
ignore: [`**/**/CHANGELOG.md`, '**/*.{js,json}'],
},
})),
];
}
async function getGatsbyConfig() {
const packageFilesPlugins = await getPackagePlugins();
return {
siteMetadata: {
title: `KeystoneJS`,
siteUrl: `https://keystonejs.com`,
description: `A scalable platform and CMS to build Node.js applications.`,
twitter: `@keystonejs`,
},
plugins: [
...packageFilesPlugins,
`gatsby-plugin-sharp`, // image processing
`gatsby-plugin-react-helmet`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: 'KeystoneJS Docs',
short_name: 'Docs',
icons: [
{
src: '/android-chrome-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/android-chrome-512x512.png',
sizes: '512x512',
type: 'image/png',
},
],
theme_color: '#ffffff',
background_color: '#ffffff',
display: 'standalone',
},
},
{
// https://github.com/gatsbyjs/gatsby/issues/15486#issuecomment-509405867
resolve: `gatsby-transformer-remark`,
options: {
plugins: [`gatsby-remark-images`],
},
},
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: ['.mdx', '.md'],
defaultLayouts: {
default: require.resolve('./src/components/markdown/mdx-renderer.js'),
},
gatsbyRemarkPlugins: [
{
resolve: 'gatsby-remark-autolink-headers',
options: {
icon: false, // we include our own icon
},
},
{ resolve: require.resolve('./plugins/gatsby-remark-fix-links') },
{
resolve: 'gatsby-remark-images',
options: {
maxWidth: 848, // TODO: remove magic number -- width of main col
},
},
// This is needed to resolve svgs
{ resolve: 'gatsby-remark-copy-linked-files' },
],
rehypePlugins: [[require('@mapbox/rehype-prism'), { ignoreMissing: true }]],
},
},
{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: 'UA-43970386-3',
head: true,
},
},
`gatsby-plugin-sitemap`,
],
};
}
module.exports = getGatsbyConfig();