-
Notifications
You must be signed in to change notification settings - Fork 1
/
docusaurus.config.js
316 lines (290 loc) · 8.05 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
const path = require('path');
const fs = require('fs');
const AT_NOTATION_KEYS = {
short: 'Short',
type: 'Type',
descr: 'Descr',
changelog: 'Changelog',
signature: 'Signature',
params: 'Params',
returns: 'Returns',
values: 'Values'
};
const COMPONENTS_PATH = '@site/src/components';
let components = { Disqus: "Disqus" };
let metaDescription = '';
const wrapDataWithComponent = (data, componentName) => {
return componentName ? `\n<${componentName}>\n${data}\n\n</${componentName}>\n\n` : data;
}
const onAtNotationMatch = (data, { key }) => {
const componentName = AT_NOTATION_KEYS[key];
if (componentName) {
components[componentName] = componentName;
}
switch(key) {
case 'default':
return `<strong>Default value: </strong> ${data}`;
case 'example':
return `**Example**\n~~~js\n${data.replace(/^(?:\n*)([^]+?)(?:\n*)$/g, '$1')}\n~~~`;
case 'metadescr':
metaDescription = data.replace(/^(?:\n*)(.+)(?:\n|.)*/, '$1');
return '';
// TODO: remove later
case 'relatedsample':
return data;
default:
return componentName
? wrapDataWithComponent(data, componentName)
: data;
}
};
const onAtNotationFunctionMatch = (data, { key, fullMatch, dir }) => {
if (data.indexOf('.md') !== -1 || data.indexOf('.mdx') !== -1 || data.indexOf('.') === -1) {
const result = readFile(dir, data);
return result ? /@short: (.*)/g.exec(result)[1] : fullMatch;
}
return fullMatch;
}
const onBraceNotationMatch = (data, { key, fullMatch }) => {
switch(key) {
case 'note':
return `:::note\n${data}\n:::`;
case 'pronote':
return `:::tip Pro version only\n${data}\n:::`;
case 'editor':
return data;
default:
return fullMatch;
}
};
const readFile = (workingDir, filePath) => {
workingDir = workingDir.replace(/\\/g, '/');
filePath = filePath.replace(/\\/g, '/');
let finalPath = workingDir + '/' + filePath;
if (finalPath.indexOf('.') === -1) {
finalPath += !fs.existsSync(finalPath + '.md') ? '.mdx' : '.md';
}
if (!fs.existsSync(finalPath)) {
const clippedFilePath = filePath.split('/');
clippedFilePath.shift();
if (!clippedFilePath.length) {
return false;
}
return readFile(workingDir, clippedFilePath.join('/'));
}
return fs.readFileSync(path.normalize(finalPath), 'utf8');
};
const onEmptyLinkMatch = (data, { key, fullMatch, dir }) => {
const filePath = fullMatch.substring(fullMatch.indexOf('(') + 1, fullMatch.length - 1);
if (filePath.indexOf('.md') !== -1 || filePath.indexOf('.mdx') !== -1 || filePath.indexOf('.') === -1) {
const data = readFile(dir, filePath);
return data ? `[${/.*sidebar_label: (.+)/g.exec(data)[1]}]${fullMatch.match(/\(\D+\)/g)[0]}` : fullMatch;
}
return fullMatch;
};
const onAfterDataTransformation = (data) => {
const allAvailableComponents = Object.values(components);
let transformedData = data;
if (allAvailableComponents.length !== 0) {
const imports = `import { ${allAvailableComponents.join(', ')} } from '${COMPONENTS_PATH}';\n\n`;
const isTitles = /---((?:\r?\n|\r)|.)+?---/.test(transformedData);
transformedData = isTitles
? (transformedData.replace(/^(---((?:\s*\n)|.)+?---)/, `$1\n\n${imports}`) + "\n\n<Disqus />")
: imports + transformedData;
}
if (metaDescription) {
transformedData = transformedData.replace(/^(---\s*\n)((?:\n|.)+?)(---\s*?\n*)/, (fullMatch, groupA, groupB, groupC) => {
const isDocusaurusDescriptionExist = /^description: *.*\n/m.test(fullMatch);
if (!isDocusaurusDescriptionExist) {
return `${groupA}description: ${metaDescription}\n${groupB}${groupC}`;
}
return fullMatch;
});
}
components = { Disqus: "Disqus" };
metaDescription = '';
return transformedData;
};
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
// const lightCodeTheme = require('prism-react-renderer/themes/github');
// const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
noIndex: false,
title: 'DHTMLX JavaScript Kanban Docs',
tagline: 'DHTMLX JavaScript Kanban Docs',
url: 'https://docs.dhtmlx.com',
baseUrl: '/kanban/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
onBrokenAnchors: 'warn',
favicon: 'img/favicon.ico',
organizationName: 'DHTMLX', // Usually your GitHub org/user name.
projectName: 'docs-kanban', // Usually your repo name.
trailingSlash: true,
scripts:[
{
src: 'https://dhtmlx.com/gtag/docs.js',
async: true
}
],
stylesheets: [
{ href:'https://cdn.jsdelivr.net/gh/orestbida/cookieconsent@3.0.1/dist/cookieconsent.css' },
],
presets: [
[
'@docusaurus/preset-classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://github.com/DHTMLX/docs-kanban/edit/master/',
routeBasePath: '/'
},
theme: {
customCss: require.resolve('./src/css/custom.css')
},
sitemap: {
changefreq: 'daily',
priority: 0.5
}
})
]
],
plugins: [
'docusaurus-plugin-sass',
[
path.resolve(__dirname, './plugins/dhx-md-data-transformer-plugin'),
{
onBraceNotationMatch,
onAtNotationMatch,
onAtNotationFunctionMatch,
onEmptyLinkMatch,
onAfterDataTransformation
}
]
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
navbar: {
title: 'JavaScript Kanban Documentation',
logo: {
alt: 'DHTMLX JavaScript Kanban Logo',
src: 'img/logo.svg',
href: 'https://docs.dhtmlx.com/'
},
items: [
{
"label": "Examples",
"href": "https://snippet.dhtmlx.com/5hcx01h4?tag=kanban",
"position": "right"
},
{
"label": "Forum",
"href": "https://forum.dhtmlx.com/c/kanban/",
"position": "right"
},
{
"label": "Support",
"href": "https://dhtmlx.com/docs/technical-support.shtml",
"position": "right"
},
{
"label": "Download",
"href": "https://dhtmlx.com/docs/products/dhtmlxKanban/download.shtml",
"position": "right"
}
],
},
footer: {
"style": "dark",
"links": [
{
"title": "Development center",
"items": [
{
"label": "Download JS Kanban",
"href": "https://dhtmlx.com/docs/products/dhtmlxKanban/download.shtml",
"position": "right"
},
{
"label": "Examples",
"href": "https://snippet.dhtmlx.com/5hcx01h4?tag=kanban",
"position": "right"
},
{
"label": "Blog",
"href": "https://dhtmlx.com/blog/tag/kanban/"
},
{
"label": "Forum",
"href": "https://forum.dhtmlx.com/c/kanban/",
"position": "right"
}
]
},
{
"title": "Community",
"items": [
{
"label": "GitHub",
"href": "https://github.com/DHTMLX"
},
{
"label": "Youtube",
"href": "https://www.youtube.com/user/dhtmlx"
},
{
"label": "Facebook",
"href": "https://www.facebook.com/dhtmlx"
},
{
"label": "Twitter",
"href": "https://twitter.com/dhtmlx"
},
{
"label": "Linkedin",
"href": "https://www.linkedin.com/groups/3345009/"
}
]
},
{
"title": "Company",
"items": [
{
"label": "About us",
"href": "https://dhtmlx.com/docs/company.shtml"
},
{
"label": "Contact us",
"href": "https://dhtmlx.com/docs/contact.shtml"
},
{
"label": "Licensing",
"href": "https://dhtmlx.com/docs/products/dhtmlxKanban/#licensing"
}
]
}
]
},
prism: {
//theme: lightCodeTheme,
//darkTheme: darkCodeTheme,
},
algolia: {
// This is a read-only, search-only key served directly by the front-end, managed by Algolia via their
// free DocSearch program. The key is not sensitive. See https://docsearch.algolia.com/ for more details.
appId: '0O8M0T0DUJ',
apiKey: '541438887f3386a7cdb48fb77176a184',
indexName: 'kanban',
// Optional: see doc section bellow
contextualSearch: true,
// Optional: Algolia search parameters
searchParameters: {}
//... other Algolia params
}
})
};
module.exports = config;