-
Notifications
You must be signed in to change notification settings - Fork 3
/
docusaurus.config.js
265 lines (249 loc) · 7.4 KB
/
docusaurus.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
// @ts-check
/* eslint-disable @typescript-eslint/no-var-requires */
const tailwindCss = require('tailwindcss');
const autoPrefixer = require('autoprefixer');
const lightCodeTheme = require('./src/prismLight');
const darkCodeTheme = require('./src/prismDark');
const { imports } = require('./src/importMap.json');
/* eslint-enable @typescript-eslint/no-var-requires */
const DEFAULT_EDIT_URL = 'https://github.com/JoinColony/docs/edit/main';
const getLibraryEditUrl = ({ versionDocsDirPath: path, docPath }) => {
// Remove edit link from auto-generate docs
if (docPath.startsWith('api') || docPath.startsWith('interfaces')) {
return null;
}
const LIB_ROOT_EDIT_URL = 'https://github.com/JoinColony';
if (path.includes('colonyNetwork')) {
return `${LIB_ROOT_EDIT_URL}/colonyNetwork/edit/develop/docs/${docPath}`;
}
if (path.includes('colonyJS/packages/sdk')) {
return `${LIB_ROOT_EDIT_URL}/colonyJS/edit/main/packages/sdk/docs/${docPath}`;
}
if (path.includes('colonyJS/packages/colony-js')) {
return `${LIB_ROOT_EDIT_URL}/colonyJS/edit/main/packages/colony-js/docs/${docPath}`;
}
return null;
};
async function capitalizeSidebarItems({
defaultSidebarItemsGenerator,
...args
}) {
const items = await defaultSidebarItemsGenerator(args);
items.forEach((mainItem) => {
if (mainItem.items) {
mainItem.items = mainItem.items.map((item) => {
if (item.label) {
item.label = item.label.replace(/^([a-z])/, (m) => m.toUpperCase());
}
return item;
});
}
});
return items;
}
const pluginsBase = [
[
'@docusaurus/plugin-content-docs',
{
id: 'docs',
path: 'colony',
routeBasePath: '/',
sidebarPath: require.resolve('./colony/sidebars.ts'),
editUrl: DEFAULT_EDIT_URL,
},
],
function reconfigureWebpack() {
return {
name: 'webpack-config',
configureWebpack(config, isServer) {
// Set target for client to suppoer import() syntax
if (!isServer) {
config.target = ['web', 'es2020'];
}
// Set externals for client to load ethers and sdk
config.externalsType = 'import';
config.externals = imports;
// SVG fixes
// https://github.com/facebook/docusaurus/issues/8297
// This is quite brittle, I just hope they provide a better way to access the svgo options at some point
const svgRuleIndex = config.module.rules.findIndex((r) =>
r.test.test('file.svg'),
);
const svgrConfigIndex = config.module.rules[
svgRuleIndex
].oneOf.findIndex((r) => {
if (!Array.isArray(r.use) || r.use.length === 0) return false;
return r.use[0].loader.indexOf('@svgr/webpack') !== -1;
});
if (svgRuleIndex === -1 || svgrConfigIndex === -1) return;
config.module.rules[svgRuleIndex].oneOf[
svgrConfigIndex
].use[0].options.svgoConfig.plugins[0].params.overrides.cleanupIDs = false;
},
};
},
function tailwindcss() {
return {
name: 'docusaurus-tailwindcss',
configurePostCss(config) {
// Appends TailwindCSS and AutoPrefixer.
config.plugins.push(tailwindCss);
config.plugins.push(autoPrefixer);
return config;
},
};
},
];
const pluginsFull = [
[
'@docusaurus/plugin-content-docs',
{
id: 'develop_colonysdk',
path: 'vendor/colonyJS/packages/sdk/docs',
routeBasePath: 'colonysdk',
sidebarPath: require.resolve('./sidebars.ts'),
sidebarItemsGenerator: capitalizeSidebarItems,
editUrl: getLibraryEditUrl,
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'develop_colonynetwork',
path: 'vendor/colonyNetwork/docs',
routeBasePath: 'colonynetwork',
sidebarPath: require.resolve('./sidebars.ts'),
sidebarItemsGenerator: capitalizeSidebarItems,
editUrl: getLibraryEditUrl,
},
],
[
'@docusaurus/plugin-content-docs',
{
id: 'develop_colonyjs',
path: 'vendor/colonyJS/packages/colony-js/docs',
routeBasePath: 'colonyjs',
sidebarPath: require.resolve('./sidebars.ts'),
sidebarItemsGenerator: capitalizeSidebarItems,
editUrl: getLibraryEditUrl,
},
],
];
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Colony Knowledge Realm',
tagline: 'Explore the vast possibilities of the Colony Network',
url: 'https://docs.colony.io',
baseUrl: process.env.QA ? '/next/' : '/',
onBrokenLinks: process.env.QA ? 'warn' : process.env.FULL ? 'throw' : 'log',
onBrokenMarkdownLinks: process.env.QA
? 'warn'
: process.env.FULL
? 'throw'
: 'log',
favicon: 'img/logo.png',
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'JoinColony', // Usually your GitHub org/user name.
projectName: 'docs', // Usually your repo name.
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
presets: [
[
'@docusaurus/preset-classic',
/** @type {import('@docusaurus/preset-classic').Options} */
{
docs: false,
blog: false,
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
pages: {
path: 'src/pages',
},
},
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
algolia: {
appId: 'ZFUKNKZFFL',
apiKey: '286f37a3de8d2dd5172c0cce745a87f4',
indexName: 'colony_docs',
contextualSearch: true,
},
navbar: {
logo: {
alt: 'Colony Logo',
src: 'img/logo.svg',
},
style: 'dark',
items: [
{
type: 'doc',
docsPluginId: 'docs',
docId: 'learn/index',
position: 'right',
label: 'Learn',
className: 'navbarSectionLearn',
},
{
type: 'doc',
docsPluginId: 'docs',
docId: 'develop/index',
position: 'right',
label: 'Develop',
className: 'navbarSectionDevelop',
},
],
},
footer: {
logo: {
alt: 'Colony Logo',
src: 'img/logo.svg',
},
style: 'dark',
links: [
{
title: 'Community',
items: [
{
label: 'Discord',
href: 'https://discord.gg/feVZWwysqM',
},
{
label: 'Twitter',
href: 'https://twitter.com/JoinColony',
},
],
},
{
title: 'More',
items: [
{
label: 'GitHub',
href: 'https://github.com/JoinColony',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Colony. Built with Docusaurus.`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
colorMode: {
defaultMode: 'dark',
},
}),
plugins: process.env.FULL ? [...pluginsBase, ...pluginsFull] : pluginsBase,
clientModules: [require.resolve('./src/piwik.js')],
};
module.exports = config;