-
Notifications
You must be signed in to change notification settings - Fork 13
/
gatsby-config.js
186 lines (183 loc) · 4.9 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
const path = require('path')
const dict = require('./dict')
const blackDict = require('./blackDict')
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`,
})
const { NODE_ENV, CONTEXT: NETLIFY_ENV = NODE_ENV } = process.env
module.exports = {
siteMetadata: {
title: `Serverless 中文技术社区 - serverlesscloud.cn`,
description: `Serverless中文技术社区是国内开发者技术交流社区。提供Serverless最新信息、实践案例、技术博客、组件文档、学习资源,帮助开发者快速应用Severless技术和解决开发中的问题。`,
author: '',
siteUrl: `https://serverlesscloud.cn`,
},
plugins: [
`gatsby-plugin-less`,
`gatsby-plugin-react-helmet`,
{
resolve: 'gatsby-plugin-hubspot-new',
options: {
trackingCode: '20280361',
respectDNT: true,
productionOnly: false,
},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-extract-keywords-jieba`,
options: {
max: 10,
process: body => {
const result = []
dict.forEach(item => {
if (body.includes(item)) {
result.push(item)
}
})
return result
},
afterProcess: (important, keywords) => {
keywords.forEach(item => {
if (/\d+/.test(item)) {
return
}
if (/[0-9'\"{}\\(\\)\\[\\]\\*&.?!,…:;]+/.test(item)) {
return
}
if (/[A-Z]{2}/.test(item)) {
return
}
if (blackDict.includes(item)) {
return
}
important.push(item)
})
console.log(important)
return important
},
},
},
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 800,
},
},
{
resolve: 'gatsby-remark-code-buttons',
options: {
toasterText: '代码复制成功',
buttonText: '复制代码',
},
},
`gatsby-remark-autolink-headers`,
`gatsby-remark-prismjs`,
],
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `data`,
path: `${__dirname}/content`,
},
},
`gatsby-plugin-sharp`,
`gatsby-transformer-sharp`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/assets/images`,
},
},
{
resolve: 'gatsby-plugin-alias-imports',
options: {
alias: {
'@src': path.resolve(__dirname, 'src'),
},
},
},
`gatsby-plugin-styled-components`,
`gatsby-plugin-typescript`,
{
resolve: `gatsby-plugin-google-analytics`,
options: {
// replace "UA-XXXXXXXXX-X" with your own Tracking ID
trackingId: 'UA-151120017-1',
},
},
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `Serverless 中文技术社区`,
short_name: `ServerlessCN`,
start_url: `/`,
background_color: `#0052D9`,
theme_color: `#0052D9`,
display: `minimal-ui`,
icon: `src/assets/images/icon-serverless-framework.png`, // This path is relative to the root of the site.
},
},
{
resolve: `gatsby-plugin-sitemap`,
options: {
sitemapSize: 5000,
query: `
{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
edges {
node {
path
}
}
}
}`,
output: `/sitemap.xml`,
exclude: [`/404`, `/404.html`],
createLinkInHead: true,
serialize: ({ site, allSitePage }) =>
allSitePage.edges.map(edge => {
return {
url: site.siteMetadata.siteUrl + edge.node.path,
changefreq: `daily`,
priority: 0.7,
}
}),
},
},
{
resolve: 'gatsby-plugin-robots-txt',
options: {
resolveEnv: () => NETLIFY_ENV,
env: {
production: {
policy: [],
sitemap: null,
host: null,
},
'branch-deploy': {
policy: [{ userAgent: '*', disallow: ['/'] }],
sitemap: null,
host: null,
},
'deploy-preview': {
policy: [{ userAgent: '*', disallow: ['/'] }],
sitemap: null,
host: null,
},
},
},
},
],
}