-
Notifications
You must be signed in to change notification settings - Fork 5
/
docusaurus.config.ts
245 lines (237 loc) · 6.32 KB
/
docusaurus.config.ts
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
import type { Config } from '@docusaurus/types';
import type { Options as PluginDocsOptions } from '@docusaurus/plugin-content-docs';
import type { Options as PluginGTagOptions } from '@docusaurus/plugin-google-gtag';
import type { Options as ThemeOptions } from '@docusaurus/theme-classic';
import type { UserThemeConfig } from '@docusaurus/theme-common';
import { visit } from 'unist-util-visit';
import { themes as prismThemes } from 'prism-react-renderer';
const lightCodeTheme = prismThemes.github;
const darkCodeTheme = prismThemes.dracula;
/**
* Docusaurus does not process JSX `<img src ="...">` URLs
* This plugin rewrites the src attribute to `src="/docs/..."`
* Markdown links `[]()`, images `![](/image)` and anchor `<a href="...">`
* are already automatically processed.
* Note that this is a hack, and it's ideal to instead prefer using `require`.
* However those images would not be viewable in the GitHub markdown.
*/
const remarkImageSrcWithDocsPrefix = () => {
return (tree) => {
visit(tree, 'mdxJsxFlowElement', (node) => {
if (node.name === 'img') {
const srcAttribute = node.attributes.find(
(attr) => attr.name === 'src',
);
if (
srcAttribute != null &&
typeof srcAttribute.value === 'string' &&
srcAttribute.value.startsWith('/images/')
) {
srcAttribute.value = `/docs${srcAttribute.value}`;
}
}
});
};
};
const pluginDocs: [string, PluginDocsOptions] = [
'@docusaurus/plugin-content-docs',
{
path: 'docs',
routeBasePath: '/',
sidebarPath: './sidebars.ts',
remarkPlugins: [remarkImageSrcWithDocsPrefix],
include: ['**/*.md', '**/*.mdx'],
exclude: ['**/_*.{js,jsx,ts,tsx,md,mdx}', '**/_*/**', '**/.**'],
},
];
const pluginGTag: [string, PluginGTagOptions] = [
'@docusaurus/plugin-google-gtag',
{
trackingID: 'G-GSMHXNB32E',
anonymizeIP: false,
},
];
const pluginTheme: [string, ThemeOptions] = [
'@docusaurus/theme-classic',
{
customCss: require.resolve('./src/css/custom.css'),
},
];
const themeConfig: UserThemeConfig = {
colorMode: {
disableSwitch: true,
},
navbar: {
logo: {
alt: 'Polykey Logo',
src: 'images/polykey-logotype-light-light.svg',
href: 'https://polykey.com',
target: '_self',
},
items: [
{
label: 'Home',
to: 'pathname:///',
autoAddBaseUrl: false,
target: '_self',
position: 'right',
},
{
label: 'Download',
to: 'pathname:///download',
autoAddBaseUrl: false,
target: '_self',
position: 'right',
},
{
label: 'Blog',
to: 'pathname:///blog',
autoAddBaseUrl: false,
target: '_self',
position: 'right',
},
{
label: 'Docs',
to: '/docs/',
position: 'right',
},
{
label: 'GitHub',
to: 'https://github.com/MatrixAI/Polykey',
position: 'right',
},
],
},
footer: {
style: 'dark',
logo: {
alt: 'Polykey Logo',
src: 'images/polykey-logotype-light-light.svg',
href: 'https://polykey.com',
target: '_self',
},
links: [
{
title: 'Resources',
items: [
{
label: 'Download',
to: 'pathname:///download',
autoAddBaseUrl: false,
target: '_self',
},
{
label: 'Blog',
to: 'pathname:///blog',
autoAddBaseUrl: false,
target: '_self',
},
{
label: 'Docs',
to: '/docs/',
},
{
label: 'Mainnet Network',
to: 'https://mainnet.polykey.com',
},
{
label: 'Testnet Network',
to: 'https://testnet.polykey.com',
},
],
},
{
title: 'Community',
items: [
{
label: 'Discord',
to: 'https://discord.gg/vfXQZwwugc',
},
{
label: 'Twitter/X',
to: 'https://twitter.com/PolykeyIO',
},
{
label: 'Stack Overflow',
to: 'https://stackoverflow.com/questions/tagged/polykey',
},
],
},
{
title: 'Open Source',
items: [
{
label: 'Polykey Core',
to: 'https://github.com/MatrixAI/Polykey',
},
{
label: 'Polykey CLI',
to: 'https://github.com/MatrixAI/Polykey-CLI',
},
{
label: 'Polykey Desktop',
to: 'https://github.com/MatrixAI/Polykey-Desktop',
},
{
label: 'Polykey Mobile',
to: 'https://github.com/MatrixAI/Polykey-Mobile',
},
],
},
{
title: 'Company',
items: [
{
label: 'Matrix AI',
to: 'https://matrix.ai',
},
{
label: 'About Us',
to: 'https://matrix.ai/about',
},
{
label: 'Terms of Service',
to: 'pathname:///terms-of-service',
autoAddBaseUrl: false,
target: '_self',
},
{
label: 'Privacy Policy',
to: 'pathname:///privacy-policy',
autoAddBaseUrl: false,
target: '_self',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Matrix AI`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ['shell-session'],
},
};
const config: Config = {
title: 'Polykey Documentation',
tagline: 'Tutorials, How-To Guides, Theory and Reference',
url: 'https://polykey.com',
// The `baseUrl` always must end with a trailing slash.
baseUrl: '/docs/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
// This ensures that `/x.md` is generated as `/x/index.html` and not `/x.html`.
// Which is the expected directory layout for most web servers.
trailingSlash: undefined,
favicon: 'images/polykey-favicon.png',
organizationName: 'MatrixAI',
projectName: 'PolyKey-Docs',
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
staticDirectories: ['static'],
plugins: [pluginDocs, pluginTheme, pluginGTag],
themeConfig,
};
export default config;