forked from pmndrs/jotai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-config.js
147 lines (138 loc) · 3.59 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
/* eslint-disable @typescript-eslint/no-var-requires */
require('dotenv').config();
const kebabCase = require('just-kebab-case');
const getAnchor = (value) => {
return typeof value === 'string' ? kebabCase(value.toLowerCase().replaceAll("'", '')) : '';
};
const DOCS_QUERY = `
query {
allMdx {
nodes {
slug
meta: frontmatter {
title
description
keywords
}
headings(depth: h2) {
value
}
excerpt
rawBody
}
}
}
`;
const queries = [
{
query: DOCS_QUERY,
transformer: ({ data }) => {
const results = [];
data.allMdx.nodes.forEach((item) => {
const transformedNode = {
objectID: item.slug,
slug: item.slug,
title: item.meta.title,
description: item.meta.description,
keywords: item.meta?.keywords?.split(',') ?? [],
excerpt: item.excerpt,
headings: item.headings.map((heading) => heading.value).join(' '),
body: item.rawBody.replace(/(<([^>]+)>)/gi, ''),
level: 1,
};
if (item.slug !== 'introduction') {
item.headings
.map((heading) => heading.value)
.forEach((heading) => {
const transformedNode = {
objectID: `${item.slug}#${getAnchor(heading)}`,
slug: `${item.slug}#${getAnchor(heading)}`,
title: heading,
description: '',
keywords: [],
excerpt: '',
headings: [],
body: '',
level: 2,
};
results.push(transformedNode);
});
}
results.push(transformedNode);
});
return results;
},
indexName: 'Docs',
settings: {
searchableAttributes: [
'slug',
'title',
'description',
'keywords',
'excerpt',
'headings',
'body',
],
indexLanguages: ['en'],
},
mergeSettings: false,
},
];
module.exports = {
siteMetadata: {
title: `Jotai, primitive and flexible state management for React`,
description: `Jotai takes a bottom-up approach to global React state management with an atomic model inspired by Recoil. One can build state by combining atoms and renders are optimized based on atom dependency. This solves the extra re-render issue of React context and eliminates the need for memoization.`,
siteUrl: `https://jotai.org`,
shortName: `Jotai`,
},
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
name: `docs`,
path: `../docs`,
},
},
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.md`, `.mdx`],
},
},
`gatsby-plugin-postcss`,
{
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.GATSBY_ALGOLIA_APP_ID,
apiKey: process.env.ALGOLIA_ADMIN_KEY,
queries,
// skipIndexing: process.env.ALGOLIA_SKIP_INDEXING === 'true',
},
},
`gatsby-plugin-sitemap`,
{
resolve: `gatsby-plugin-google-gtag`,
options: {
trackingIds: ['G-WWJ8XD0QP0'],
gtagConfig: {
anonymize_ip: true,
cookie_expires: 0,
},
pluginConfig: {
head: false,
respectDNT: true,
},
},
},
],
flags: {
DEV_SSR: false,
LAZY_IMAGES: true,
PRESERVE_FILE_DOWNLOAD_CACHE: true,
PARALLEL_SOURCING: true,
},
graphqlTypegen: false,
jsxRuntime: 'automatic',
polyfill: false,
trailingSlash: 'never',
};