/
docusaurus.config.js
160 lines (156 loc) · 4.18 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
const fs = require('fs');
const path = require('path');
const remarkAbbr = require('remark-abbr');
const remarkMath = require('remark-math');
const rehypeKatex = require('rehype-katex');
const sidebars = require('./sidebars.js');
function extractTitleFromMarkdown(docPath) {
const content = fs.readFileSync(path.join(__dirname, 'docs', docPath), { encoding: 'utf8' });
const found = content.match(/title:\s*([^\r\n]+)/);
if (found === null) {
throw new Error(`Couldn't find title in ${docPath}`);
}
return found[1];
}
function process_category_items(items) {
if (!items) {
return [];
}
let result = [];
for (const item of items) {
if (typeof item === 'string' || item instanceof String) {
result.push({
type: 'doc',
label: extractTitleFromMarkdown(item + '.md'),
id: item,
});
continue;
}
switch (item.type) {
case 'doc': {
result.push({
type: 'doc',
label: extractTitleFromMarkdown(item.id + '.md'),
id: item.id,
});
break;
}
case 'category': {
result.push({
type: 'category',
label: item.label,
items: process_category_items(item.items),
});
break;
}
}
}
return result;
}
const sitemap = {}
for (const [category, categoryItems] of Object.entries(sidebars)) {
sitemap[category] = process_category_items(categoryItems);
}
module.exports = {
title: 'Algoua',
tagline: 'Алгоритмічні навчальні матеріали',
url: 'https://algoua.com',
baseUrl: '/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',
organizationName: 'algoua',
projectName: 'algoua',
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css',
type: 'text/css',
integrity: 'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
crossorigin: 'anonymous',
},
],
themeConfig: {
docs: {
sidebar: {
hideable: true,
}
},
announcementBar: {
id: 'announcementBar-1', // Increment on change
content:
'⭐️ If you like Algoua, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://github.com/algoua/algoua">GitHub</a>! ⭐',
},
prism: {
theme: require('prism-react-renderer/themes/github'),
darkTheme: require('prism-react-renderer/themes/palenight'),
},
navbar: {
title: 'Algoua',
logo: {
alt: 'Algoua Logo',
src: 'img/logo.svg',
},
items: [
{
to: 'books/',
activeBasePath: 'books',
label: 'Література',
position: 'left',
},
{
href: 'https://github.com/algoua/algoua',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
items: [
{
label: 'Зв\'язатися',
href: 'https://github.com/algoua/algoua/issues/new',
},
{
label: 'Як запропонувати зміни чи додати нову статтю?',
href: 'https://github.com/algoua/algoua#внесення-змін',
},
],
},
],
copyright: `Logo is based on an icon made by <a href="https://www.flaticon.com/authors/becris" title="Becris" class="copyright-link">Becris</a><br/>
Copyright © ${new Date().getFullYear()} Algoua`,
},
},
presets: [
[
'@docusaurus/preset-classic',
{
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js'),
remarkPlugins: [remarkAbbr, remarkMath],
rehypePlugins: [rehypeKatex],
showLastUpdateTime: false,
editUrl: 'https://github.com/algoua/algoua/edit/main/',
},
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
],
plugins: [
[
require.resolve('docusaurus-lunr-search'),
{
languages: ['en', 'ru'],
},
],
],
customFields: {
sitemap,
},
};