Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
271 lines (249 loc) · 9.66 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
271 lines (249 loc) · 9.66 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
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import {redirects} from './src/redirects';
import {docs, versionedDocs, versionedInstances, latestSegs, canonicalSitemapItems, parseFrontMatter} from './src/docsPlugins';
import {variables, versionedVariables} from './src/variables';
// Retired versions served as static Antora HTML from a separate site. See plugins/archived-versions.
const archivedVersions: {origin: string; versions: Record<string, string[]>} = require('./src/archivedVersions.json');
// Links from a product's version dropdown to its newest archived version, whose own picker lists the rest.
// `pathname://` keeps the link out of the router and the broken-link check, because the page is not in this build.
const archivedVersionsItem = (product: string) => [
{href: `pathname:///${product}/${archivedVersions.versions[product][0]}/`, label: 'Archives', target: '_self', className: 'archived-versions-link'},
];
// DOCS_ESCROW=true builds the HTML for the source code escrow package (hazelcast-release-engineering):
// only the escrow products, and a hash router so the pages open from the file system.
// https://hazelcast.atlassian.net/wiki/spaces/DI/pages/4454711322/Escrow+Deposit+Releases
const escrow = process.env.DOCS_ESCROW === 'true';
const escrowProducts = ['hazelcast', 'management-center', 'clc'];
const included = (id: string) => !escrow || escrowProducts.includes(id);
// Product tabs, also listed in a "Products" dropdown that replaces them at narrow desktop widths (see custom.css).
const products = [
{docsPluginId: 'hazelcast', label: 'Platform'},
{docsPluginId: 'management-center', label: 'Management Center'},
{docsPluginId: 'operator', label: 'Operator'},
{docsPluginId: 'cloud', label: 'Cloud'},
{docsPluginId: 'clc', label: 'CLC'},
]
.filter((product) => included(product.docsPluginId))
.map((product) => ({type: 'docSidebar', sidebarId: 'defaultSidebar', ...product}));
const config: Config = {
title: 'Hazelcast Documentation',
tagline: 'Hazelcast product documentation',
favicon: 'img/favicon.ico',
future: {
v4: true,
...(escrow && {experimental_router: 'hash' as const}),
},
// The origin baked into every canonical tag and sitemap entry.
url: 'https://docs.hazelcast.com',
baseUrl: '/',
// Netlify canonicalizes slashes from the file layout, so this reproduces
// Antora's URL shape (`/cloud/overview` canonical, the slashed form 301s to
// it) with no explicit redirects.
trailingSlash: false,
// '.api-specs' is staged by plugins/openapi-specs; listing it here serves it like `static`.
staticDirectories: ['static', '.api-specs'],
onBrokenLinks: 'throw',
onBrokenAnchors: 'warn',
markdown: {
parseFrontMatter,
hooks: {
onBrokenMarkdownLinks: 'throw',
onBrokenMarkdownImages: 'throw',
},
},
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
presets: [
[
'classic',
{
docs: false,
blog: false,
// The container also loads the Enzuzo cookie banner, so there is deliberately
// no Enzuzo script in this repo. Runs only when NODE_ENV=production.
googleTagManager: {
containerId: 'GTM-MQ59XD6',
},
// The sitemap lists canonical URLs only, to agree with the cross-version canonicals.
sitemap: {
createSitemapItems: async ({defaultCreateSitemapItems, ...params}) =>
canonicalSitemapItems(await defaultCreateSitemapItems(params)),
},
theme: {
customCss: [
require.resolve('@hazelcast/ui/styles/variables.css'),
require.resolve('@hazelcast/ui/styles/typography/open-sans.css'),
require.resolve('@hazelcast/ui/styles/typography/pp-telegraf.css'),
'./src/css/custom.css',
],
},
} satisfies Preset.Options,
],
],
plugins: [
'docusaurus-plugin-sass',
// Substitutes {attribute} placeholders in example files per version.
['./plugins/example-attributes', {variables, versionedVariables}],
versionedDocs('hazelcast'), // navbar label "Platform"
included('cloud') && docs('cloud'),
included('tutorials') && docs('tutorials'),
included('operator') && versionedDocs('operator'),
versionedDocs('clc'),
versionedDocs('management-center'),
[
'@docusaurus/plugin-client-redirects',
{redirects},
],
// Emits /api/cloud.json for the Cloud console.
included('cloud') && './plugins/cloud-console-index',
['./plugins/openapi-specs', {variables, versionedVariables, docs: versionedInstances}],
// Fetches from GitHub. The escrow build must not depend on external Hazelcast sources.
included('tutorials') && './plugins/tutorial-examples',
'./plugins/tutorials-index',
'./plugins/llms-txt',
// Comments on deploy-preview PRs with links to the pages they change.
'./plugins/preview-pages',
['./plugins/archived-versions', archivedVersions],
// rspack's realContentHash string-replaces hashes in the SSG bundle, page text included.
() => ({
name: 'server-real-content-hash-off',
configureWebpack: (_config: unknown, isServer: boolean) =>
isServer ? {optimization: {realContentHash: false}} : {},
}),
],
// Lets the landing page resolve its `/<comp>/latest/` links (no remark pass runs on React pages).
customFields: {latestSegs},
clientModules: [
require.resolve('./src/clientModules/kapa.ts'),
require.resolve('./src/clientModules/pushfeedback.ts'),
],
themeConfig: {
colorMode: {
respectPrefersColorScheme: true,
},
metadata: [
{
name: 'google-site-verification',
content: '3gaMIo4Cp94mol0v1ae9PNYw9xYLbP4O_IrQxSvnS7E',
},
],
// The crawler indexes only the latest release of each product, so bump its URL
// patterns when a version is cut. `contextualSearch` must stay off: it would
// return no results on older versions.
algolia: {
appId: 'QK2EAH8GB0',
apiKey: '360d69c2e5f2f150cbf4322abb413956',
indexName: 'new-docs',
contextualSearch: false,
// No `/search` route; this also drops the modal's "See all results" footer.
searchPagePath: false,
},
navbar: {
title: '',
logo: {
alt: 'Hazelcast',
src: 'img/hazelcast-logo-original.svg',
srcDark: 'img/hazelcast-logo-white.svg',
},
items: [
{
type: 'dropdown',
label: 'Products',
position: 'left',
className: 'navbar-products-dropdown',
items: products,
},
...products.map((product) => ({...product, position: 'left' as const, className: 'navbar-product-tab'})),
// Plain link: tutorials has no sidebar.
...(included('tutorials') ? [{
to: '/tutorials',
position: 'left' as const,
label: 'Tutorials',
}] : []),
{
type: 'docsVersionDropdown',
docsPluginId: 'hazelcast',
position: 'right',
dropdownItemsAfter: archivedVersionsItem('hazelcast'),
},
...(included('operator') ? [{
type: 'docsVersionDropdown',
docsPluginId: 'operator',
position: 'right' as const,
dropdownItemsAfter: archivedVersionsItem('operator'),
}] : []),
{
type: 'docsVersionDropdown',
docsPluginId: 'clc',
position: 'right',
dropdownItemsAfter: archivedVersionsItem('clc'),
},
{
type: 'docsVersionDropdown',
docsPluginId: 'management-center',
position: 'right',
dropdownItemsAfter: archivedVersionsItem('management-center'),
},
// Declared explicitly so search sits before Ask AI and the CTA.
{type: 'search', position: 'right'},
{type: 'custom-ask-ai', position: 'right'},
{type: 'custom-cta', position: 'right'},
],
},
footer: {
style: 'light',
links: [
{
items: [
{
label: 'Hazelcast.com',
href: 'https://hazelcast.com/?utm_source=docs-website',
},
{
label: 'GitHub',
href: 'https://github.com/hazelcast/hazelcast'
},
{
label: 'Terms of Service',
href: 'https://hazelcast.com/terms-of-use/?utm_source=docs-website',
},
{
label: 'Privacy',
to: '/privacy',
},
{
label: 'Contact us',
href: 'https://hazelcast.com/contact/?utm_source=docs-website',
},
{
label: 'Support',
href: 'https://support.hazelcast.com/s/?utm_source=docs-website',
},
],
},
],
},
prism: {
// The GitHub and Dracula token colours on HIVE backgrounds: `--hive-color-surface-hover-v4` in light, the raised surface `--hive-color-neutral-white-v4` in dark.
// Literals, not `var()`: the API reference passes these colours to Redoc, whose darken/transparentize cannot parse `var()`.
theme: {
...prismThemes.github,
plain: {...prismThemes.github.plain, backgroundColor: '#f5f5f5'},
},
darkTheme: {
...prismThemes.dracula,
plain: {...prismThemes.dracula.plain, backgroundColor: '#2a2d3a'},
},
// A language missing here renders unhighlighted, silently.
additionalLanguages: [
'bash', 'java', 'properties', 'csharp',
'batch', 'cmake', 'docker', 'dot', 'groovy', 'php', 'protobuf',
],
},
} satisfies Preset.ThemeConfig,
};
export default config;