forked from TryGhost/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
135 lines (128 loc) · 3.85 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const postcssCustomMedia = require(`postcss-custom-media`)
const autoprefixer = require(`autoprefixer`)
const cssVariables = require(`postcss-css-variables`)
const colorModFunction = require(`postcss-color-mod-function`)
const cssNano = require(`cssnano`)
const customProperties = require(`postcss-custom-properties`)
const easyImport = require(`postcss-easy-import`)
const algoliaQueries = require(`./src/utils/algolia-queries`)
require(`dotenv`).config({
path: `.env.${process.env.NODE_ENV}`,
})
if (!process.env.GHOST_API_URL || !process.env.GHOST_API_KEY) {
throw new Error(
`GHOST_API_URL and GHOST_API_KEY are required to build. Check the CONTRIBUTING guide.`
)
}
const SERVICE_WORKER_KILL_SWITCH = (process.env.SERVICE_WORKER_KILL_SWITCH === `true`) || false
const plugins = [
/**
* Content Plugins
*/
{
resolve: `gatsby-source-filesystem`,
options: {
path: `${__dirname}/content/`,
name: `markdown-pages`,
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 590,
},
},
`gatsby-remark-code-titles`,
`gatsby-remark-prismjs`, // TODO: make aliases work!
`gatsby-remark-external-links`,
`gatsby-remark-autolink-headers`,
],
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-transformer-yaml`,
{
resolve: `gatsby-source-ghost`,
options: {
apiUrl: `${process.env.GHOST_API_URL}`,
clientId: `ghost-frontend`,
clientSecret: `${process.env.GHOST_API_KEY}`,
},
},
`gatsby-plugin-catch-links`,
/**
* Utility Plugins
*/
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `Ghost Docs`,
short_name: `Ghost`,
start_url: `/`,
background_color: `#343f44`,
theme_color: `#343f44`,
display: `minimal-ui`,
icon: `src/images/favicon.png`,
},
},
`gatsby-plugin-react-helmet`,
`gatsby-plugin-sitemap`,
`gatsby-plugin-force-trailing-slashes`,
/**
* Display Plugins
*/
{
resolve: `gatsby-plugin-postcss`,
options: {
postCssPlugins: [
autoprefixer({ browsers: [`last 2 versions`] }),
easyImport(),
cssVariables(),
colorModFunction(),
customProperties({ preserve: false }),
postcssCustomMedia(),
cssNano({ zindex: false }),
],
},
},
{
resolve: `gatsby-plugin-react-svg`,
options: {
rule: {
include: /icons/,
},
},
},
]
if (process.env.ALGOLIA_ADMIN_KEY && !process.env.ALGOLIA_ADMIN_KEY.match(/<key>/)) {
plugins.push({
resolve: `gatsby-plugin-algolia`,
options: {
appId: `6RCFK5TOI5`,
apiKey: `${process.env.ALGOLIA_ADMIN_KEY}`,
queries: algoliaQueries,
chunkSize: 10000, // default: 1000
},
})
}
// Global switch to either use or remove service worker
if (SERVICE_WORKER_KILL_SWITCH) {
console.log(`Remove service worker plugin`)
plugins.push(`gatsby-plugin-remove-serviceworker`)
} else {
console.log(`Install service worker plugin`)
plugins.push(`gatsby-plugin-offline`)
}
module.exports = {
siteMetadata: {
title: `Ghost Docs`,
siteUrl: process.env.SITE_URL || `https://docs.ghost.org`,
description: `Everything you need to know about working with the Ghost professional publishing platform.`,
},
plugins: plugins,
}