-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
65 lines (63 loc) · 2.44 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
const siteMetadata = require('./site-metadata.json')
const sass = require('node-sass');
const sassUtils = require('node-sass-utils')(sass);
module.exports = {
pathPrefix: '/',
siteMetadata: siteMetadata,
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-source-data`,
`gatsby-transformer-remark`,
{
resolve: `gatsby-source-filesystem`,
options: {
name: `pages`,
path: `${__dirname}/src/pages`
}
},
{
resolve: `gatsby-plugin-sass`,
options: {
functions: {
"getPaletteKey($key)": function(sassKey) {
function hexToRgb(hex) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
let sassParams = siteMetadata.palettes[siteMetadata.palette].sass;
let key = sassKey.getValue();
let value = sassParams[key];
let colorRegExp = /^#(?:[a-f\d]{3}){1,2}$/i;
let result;
if (colorRegExp.test(value)) {
result = hexToRgb(value);
result = new sass.types.Color(result.r, result.g, result.b);
} else {
result = sassUtils.castToSass(value)
}
return result;
}
}}
},
{
resolve: `gatsby-remark-page-creator`,
options: {}
},
{
resolve: `@stackbit/gatsby-plugin-menus`,
options: {
sourceUrlPath: `fields.url`,
pageContextProperty: `menus`,
}
}
]
};