-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
264 lines (240 loc) · 7.95 KB
/
docusaurus.config.js
File metadata and controls
264 lines (240 loc) · 7.95 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
// @ts-check
// `@type` JSDoc annotations allow editor autocompletion and type checking
// (when paired with `@ts-check`).
// There are various equivalent ways to declare your Docusaurus config.
// See: https://docusaurus.io/docs/api/docusaurus-config
import { themes as prismThemes } from 'prism-react-renderer';
import { generateDocusaurusPlugins, generateNavbarDropdowns, PRODUCTS, versionToUrl, getDefaultVersion } from './src/config/products.js';
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Netwrix Product Documentation',
tagline: 'Documentation for Netwrix Products',
favicon: 'branding/favicon.ico',
// Set the production url of your site here
// Use environment variable for dynamic URL configuration
projectName: 'docs',
url: process.env.APP_EXTERNAL_URL || 'http://localhost:4500',
// Set the /<baseUrl>/ pathname under which your site is served
baseUrl: '/',
// throw on anything that is not configured correctly
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
onBrokenAnchors: 'throw',
// Set Mermaid
markdown: {
mermaid: true,
},
themes: ['@docusaurus/theme-mermaid'],
// Performance optimizations with Docusaurus Faster
future: {
experimental_faster: {
swcJsLoader: true,
swcJsMinimizer: true,
swcHtmlMinimizer: true,
lightningCssMinimizer: true,
rspackBundler: true,
rspackPersistentCache: true, // 2-5x faster rebuilds
mdxCrossCompilerCache: true,
ssgWorkerThreads: false, // 2x faster static generation
},
v4: {
removeLegacyPostBuildHeadAttribute: true, // Required for worker threads
// useCssCascadeLayers: true, // Temporarily disabled - may cause style conflicts
},
},
// 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: 'en',
locales: ['en'],
},
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: false,
blog: false,
theme: {
customCss: './src/css/custom.css',
},
}),
],
],
plugins: [
// Disable scope hoisting to prevent O(n²) hang on large module graphs
function customRspackPlugin() {
return {
name: 'custom-rspack-config',
configureWebpack(_config, isServer) {
if (!isServer) {
return { optimization: { concatenateModules: false } };
}
return {};
},
};
},
// Google Analytics
[
'@docusaurus/plugin-google-gtag',
{
trackingID: 'G-FZPWSDMTEX',
anonymizeIP: true,
},
],
// Client-side redirects - redirect base product URLs to latest version
[
'@docusaurus/plugin-client-redirects',
{
redirects: PRODUCTS.filter(product => {
// Only create redirects for products with multiple versions (not just 'current')
return !(product.versions.length === 1 && product.versions[0].version === 'current');
}).map(product => {
const latestVersion = getDefaultVersion(product);
const latestVersionUrl = versionToUrl(latestVersion.version);
// Use explicit customRoutePath if specified (e.g., for multi-versioned products with 'current')
// Otherwise use standard path generation
const targetPath = latestVersion.customRoutePath
? latestVersion.customRoutePath
: `${product.path}/${latestVersionUrl}`;
return {
from: `/${product.path}`,
to: `/${targetPath}`,
};
}),
},
],
// Generate all product documentation plugins from centralized configuration
...generateDocusaurusPlugins().map(([pluginName, config]) => [
pluginName,
{
...config,
sidebarPath: config.sidebarPath && typeof config.sidebarPath === 'string'
? require.resolve(config.sidebarPath)
: config.sidebarPath,
},
]),
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// MermaidJS Config
mermaid: {
theme: {
light: 'neutral',
dark: 'dark',
},
options: {
look: 'handDrawn',
handDrawnSeed: 1,
},
},
// Replace with your project's social card
image: 'img/Logo_RGB.svg',
docs: {
sidebar: {
hideable: true,
autoCollapseCategories: false,
},
},
algolia: {
// Your Algolia credentials
appId: 'KPMSCF6G6J',
apiKey: '1b20f30f13a874cd46f9d5c30b01d99c', // Use the search-only API key, not the admin key
indexName: 'Production Docs',
// Enable contextual search (already great that you have product/version meta tags!)
contextualSearch: true,
// Search parameters for better results
searchParameters: {
// Facet filters can be combined with contextual search
// These will be merged with the automatic facets from contextual search
facetFilters: [
// Add any default filters here if needed
// e.g., 'type:content' to exclude headers-only results
],
// Attributes to snippet in search results
attributesToSnippet: ['content:20'],
// Highlight search terms in results
highlightPreTag: '<mark>',
highlightPostTag: '</mark>',
// Number of results per page
hitsPerPage: 20,
// Add these for better relevance
distinct: true,
clickAnalytics: true,
analytics: true,
},
// Enable search insights for better analytics
insights: true,
// Path for the search page (enables full-page search experience)
searchPagePath: 'search',
// Placeholder text for the search box
placeholder: 'Search the Netwrix docs...',
// Transform items before displaying (optional)
transformItems: (items) => {
return items.map((item) => {
// Add product badges or modify display as needed
return {
...item,
// Example: Add custom badges based on product
_highlightResult: {
...item._highlightResult,
// Customize highlighted results if needed
},
};
});
},
// Replace paths if you're using different deployments
// replaceSearchResultPathname: {
// from: '/docs/',
// to: '/',
// },
},
navbar: {
logo: {
alt: 'Netwrix Logo',
src: 'branding/Netwrix_Logo_Dark.svg',
srcDark: 'branding/Netwrix_Logo_Light.svg',
href: '/',
},
items: [
// Generate category dropdowns from centralized product configuration
...generateNavbarDropdowns(),
{
href: 'https://community.netwrix.com',
label: 'Community',
position: 'right',
},
{
href: 'https://www.netwrix.com/support.html',
label: 'Support',
position: 'right',
},
{
href: 'http://github.com/netwrix',
label: 'GitHub',
position: 'right',
},
],
},
prism: {
theme: prismThemes.github,
darkTheme: prismThemes.dracula,
additionalLanguages: ['powershell', 'bash'],
},
}),
// Add preconnect for better search performance
headTags: [
{
tagName: 'link',
attributes: {
rel: 'preconnect',
href: 'https://KPMSCF6G6J-dsn.algolia.net',
crossorigin: 'anonymous',
},
},
],
stylesheets: ['https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap'],
};
export default config;