-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
286 lines (270 loc) · 8.96 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
286 lines (270 loc) · 8.96 KB
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
import path from 'path';
import { promises as fs } from 'fs';
import { pathToFileURL } from 'url';
import { themes as prismThemes } from 'prism-react-renderer';
import mcpServerPlugin from 'docusaurus-plugin-mcp-server';
import type { Config, Plugin, LoadContext } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
// Absolute file:// URL works with the plugin's dynamic import() loader,
// which resolves relative paths against its own dist directory.
//
// Once https://github.com/scalvert/docusaurus-plugin-mcp-server/pull/78 lands,
// drop `mcp-providers/` and replace with `flexsearch: { tokenize: 'strict',
// context: false, ... }` directly in plugin options below.
const leanIndexerSpecifier = pathToFileURL(
path.join(__dirname, 'mcp-providers/lean-indexer.ts'),
).href;
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
// trailingSlash: false → Docusaurus emits pages as `path.html`, but
// docusaurus-plugin-mcp-server only scans `index.html`. Docusaurus runs all
// plugin postBuild hooks via Promise.all, so a separate shim plugin would
// race the MCP plugin. We wrap the MCP plugin instead and run the shim
// sequentially inside the same postBuild.
//
// Remove `shimHtmlForMcp` and `wrappedMcpPlugin` once this lands upstream:
// https://github.com/scalvert/docusaurus-plugin-mcp-server/pull/77
async function shimHtmlForMcp(outDir: string) {
const skip = new Set(['assets', 'img', 'static', 'mcp']);
async function walk(dir: string) {
const entries = await fs.readdir(dir, { withFileTypes: true });
for (const entry of entries) {
if (entry.isDirectory()) {
if (skip.has(entry.name)) continue;
await walk(path.join(dir, entry.name));
} else if (
entry.isFile() &&
entry.name.endsWith('.html') &&
entry.name !== 'index.html' &&
entry.name !== '404.html'
) {
const base = entry.name.slice(0, -'.html'.length);
const targetDir = path.join(dir, base);
const targetFile = path.join(targetDir, 'index.html');
try {
await fs.access(targetFile);
continue;
} catch {}
await fs.mkdir(targetDir, { recursive: true });
await fs.copyFile(path.join(dir, entry.name), targetFile);
}
}
}
await walk(outDir);
}
async function wrappedMcpPlugin(ctx: LoadContext, opts: unknown): Promise<Plugin> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const inner = await (mcpServerPlugin as any)(ctx, opts);
const originalPostBuild = inner.postBuild;
return {
...inner,
name: inner.name ?? 'docusaurus-plugin-mcp-server',
async postBuild(args: { outDir: string; [k: string]: unknown }) {
await shimHtmlForMcp(args.outDir);
if (originalPostBuild) {
await originalPostBuild.call(inner, args);
}
},
};
}
const config: Config = {
title: 'Справочный центр Хекслета',
tagline: 'Ответы на частые вопросы и инструкции для студентов',
favicon: 'img/favicon.ico',
plugins: [
[
wrappedMcpPlugin,
{
server: {
name: 'hexlet-help',
version: '1.0.0',
},
indexers: [leanIndexerSpecifier],
},
],
[
require.resolve("@cmfcmf/docusaurus-search-local"),
{
indexDocs: true,
indexDocSidebarParentCategories: 2,
includeParentCategoriesInPageTitle: false,
indexBlog: false,
indexPages: false,
language: ["ru", "en"],
style: undefined,
maxSearchResults: 10,
// lunr.js-specific settings
lunr: {
tokenizerSeparator: /[\s\-.,!?:;()]+/, // чуть более "мягкое" разделение слов
b: 0.6, // лёгкое снижение нормализации по длине, чтобы длинные статьи не терялись
k1: 1.2, // чуток усиливаем вклад совпадений редких терминов
titleBoost: 6, // совпадения в заголовках по-прежнему самые важные
contentBoost: 1.8, // усиливаем вклад основного текста статьи
tagsBoost: 3, // снижаем вклад тегов, чтобы они не перегружали выдачу
parentCategoriesBoost: 1.5, // навигационные категории влияют мягче
}
}
],
],
storage: {
type: 'localStorage',
namespace: true,
},
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
future: {
faster: true,
experimental_vcs: true,
v4: true,
},
// Set the production url of your site here
url: 'https://help.hexlet.io',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
trailingSlash: false,
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'hexlet', // Usually your GitHub org/user name.
projectName: 'hexlet.github.io', // Usually your repo name.
onBrokenLinks: 'throw',
// Even if you don't use internationalization, 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: 'ru',
locales: ['ru'],
},
presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebar.ts',
routeBasePath: '/',
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/hexlet/hexlet.github.io/blob/main',
},
blog: false,
sitemap: {
changefreq: 'weekly',
priority: 0.5,
},
theme: {
// customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
themeConfig: {
// algolia: {
// appId: '31S4GA91US',
// apiKey: 'fb627b1a0c425541c758c75bfd47e15c',
// indexName: 'hexlet_help_pages',
// contextualSearch: false,
// },
// Declare some <meta> tags
metadata: [
{ name: 'algolia-site-verification', content: '093713AA286F7B7D' },
],
// Replace with your project's social card
// image: 'img/docusaurus-social-card.jpg',
colorMode: {
respectPrefersColorScheme: true,
},
navbar: {
title: 'Хекслет',
logo: {
alt: 'Логотип Хекслета',
src: 'img/hexlet-logo-white-rus.png',
},
items: [
// {
// type: 'docSidebar',
// sidebarId: 'tutorialSidebar',
// position: 'left',
// label: 'Документация',
// },
{
href: 'https://t.me/hexletcommunity',
label: 'Сообщество',
position: 'left',
},
{
href: 'https://t.me/hexlet_help_bot',
label: 'Написать (ТГ)',
position: 'left',
},
{
href: 'https://github.com/Hexlet/hexlet.github.io/discussions',
label: 'Предложить улучшение',
position: 'left',
},
{
href: 'https://ru.hexlet.io',
label: 'Платформа',
position: 'right',
},
{
href: 'https://github.com/hexlet/hexlet.github.io',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Решения',
items: [
{
label: 'Компаниям',
to: 'https://b2b.hexlet.io/',
},
{
label: 'Хекслет Карьера',
to: 'https://career.hexlet.io/',
},
],
},
{
title: 'Сообщество',
items: [
{
label: 'VK',
href: 'https://vk.com/hexlet',
},
{
label: 'Телеграм-канал',
href: 'https://t.me/hexlet_ru',
},
{
label: 'YouTube-канал',
href: 'https://www.youtube.com/@HexletUniversity',
},
],
},
{
title: 'Поддержка',
items: [
{
label: 'Центр поддержки',
href: 'https://help.hexlet.io',
},
{
href: 'https://t.me/hexlet_help_bot',
label: 'Поддержка в ТГ',
},
],
},
],
copyright: `© ${new Date().getFullYear()} Хекслет.`,
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
},
} satisfies Preset.ThemeConfig,
};
export default config;