-
Notifications
You must be signed in to change notification settings - Fork 41
/
docusaurus.config.ts
373 lines (359 loc) · 11.6 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
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
import fs from 'node:fs/promises';
import { Config } from '@docusaurus/types';
import {
Options as PresetClassicOptions,
ThemeConfig as PresetClassicThemeConfig,
} from '@docusaurus/preset-classic';
import { Options as PluginContentBlogOptions } from '@docusaurus/plugin-content-blog';
import { Options as PluginGoogleAnalyticsOptions } from '@docusaurus/plugin-google-analytics';
import { Options as PluginSEOChecksOptions } from '@wasmcloud/docusaurus-seo-checks';
import { Options as PluginGithubStarsOptions } from '@wasmcloud/docusaurus-github-stars';
import { Options as PluginHubspotAnalyticsOptions } from '@wasmcloud/docusaurus-hubspot-analytics';
import rehypeShiki, { RehypeShikiOptions } from '@shikijs/rehype';
import { bundledLanguages } from 'shiki';
import {
transformerMetaHighlight,
transformerNotationDiff,
transformerNotationHighlight,
transformerNotationFocus,
} from '@shikijs/transformers';
import rehypeNameToId from 'rehype-name-to-id';
const rehypeShikiPlugin = [
rehypeShiki,
{
themes: {
dark: 'github-dark',
light: 'github-light',
},
transformers: [
{
name: 'meta',
code(node) {
const language = this.options.lang ?? 'plaintext';
this.addClassToHast(node, `language-${language}`);
return node;
},
},
transformerMetaHighlight(),
transformerNotationDiff(),
transformerNotationHighlight(),
transformerNotationFocus(),
],
langs: [
...(Object.keys(bundledLanguages) as Array<keyof typeof bundledLanguages>),
async () => JSON.parse(await fs.readFile('./languages/wit.tmLanguage.json', 'utf-8')),
async () => JSON.parse(await fs.readFile('./languages/smithy.tmLanguage.json', 'utf-8')),
],
} as RehypeShikiOptions,
];
function siteBaseUrl() {
if (process.env.NODE_ENV === 'development') {
return 'http://localhost:3000';
}
if (process.env.NETLIFY && process.env.CONTEXT === 'deploy-preview') {
return process.env.DEPLOY_PRIME_URL;
}
return 'https://wasmcloud.com';
}
const config = (async (): Promise<Config> => {
return {
title: 'wasmCloud',
tagline: 'Build applications in any language. Deploy them anywhere.',
customFields: {
description: 'The secure, distributed, WebAssembly application platform',
tagline_1: 'Build applications in any language.',
tagline_2: 'Deploy them anywhere.',
},
url: siteBaseUrl(),
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
favicon: '/favicon.ico',
// Even if you don't use internalization, 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',
{
blog: {
blogTitle: 'Blog',
blogDescription: 'The latest wasmCloud news, updates, and announcements.',
blogSidebarCount: 0,
beforeDefaultRehypePlugins: [rehypeShikiPlugin],
rehypePlugins: [rehypeNameToId],
authorsMapPath: '../authors.yml', // relative to blog directory
blogListComponent: '@theme/wasmcloud/blog/list-page',
blogPostComponent: '@theme/wasmcloud/blog/post-page',
},
docs: {
editUrl: 'https://github.com/wasmCloud/wasmcloud.com/edit/main/',
beforeDefaultRehypePlugins: [rehypeShikiPlugin],
rehypePlugins: [rehypeNameToId],
lastVersion: 'current',
versions: {
current: {
label: '1.x',
},
0.82: {
label: '0.82',
path: '0.82',
banner: 'unmaintained',
},
},
},
pages: {
beforeDefaultRehypePlugins: [rehypeShikiPlugin],
rehypePlugins: [rehypeNameToId],
},
theme: {
customCss: [require.resolve('./src/styles/index.css')],
},
} satisfies PresetClassicOptions,
],
],
plugins: [
[
'@wasmcloud/docusaurus-github-stars',
{
preloadRepo: 'wasmCloud/wasmCloud',
} satisfies PluginGithubStarsOptions,
],
[
'@wasmcloud/docusaurus-seo-checks',
{
underscores: { level: 'error' },
} satisfies PluginSEOChecksOptions,
],
[
'@docusaurus/plugin-content-blog',
{
id: 'community',
routeBasePath: 'community',
path: './community',
showReadingTime: false,
editUrl: 'https://github.com/wasmCloud/wasmcloud.com-dev/edit/main/',
blogTitle: 'Community Calls',
blogDescription: 'Weekly wasmCloud Wednesday agendas, notes, and recordings.',
blogSidebarCount: 'ALL',
blogSidebarTitle: 'Past Meetings',
beforeDefaultRehypePlugins: [rehypeShikiPlugin],
rehypePlugins: [rehypeNameToId],
authorsMapPath: '../authors.yml', // relative to community directory
blogListComponent: '@theme/wasmcloud/community/list-page',
blogPostComponent: '@theme/wasmcloud/community/post-page',
} satisfies PluginContentBlogOptions,
],
[
'@docusaurus/plugin-google-analytics',
{
trackingID: process.env.GOOGLE_ANALYTICS_ID || 'localdev',
anonymizeIP: true,
} satisfies PluginGoogleAnalyticsOptions,
],
[
'@wasmcloud/docusaurus-hubspot-analytics',
{
hubspotId: process.env.HUBSPOT_ID || 'localdev',
} satisfies PluginHubspotAnalyticsOptions,
],
customPostCssPlugin, // PostCSS plugin function registration
],
themeConfig: {
image: '/logo/wasmcloud-social.png',
navbar: {
title: 'wasmCloud',
logo: {
alt: 'wasmCloud Logo',
src: '/logo/wasmcloud_green.svg',
},
items: [
{ to: '/blog', label: 'Blog', position: 'left' },
{ to: '/community', label: 'Community', position: 'left' },
{ type: 'doc', docId: 'intro', position: 'left', label: 'Docs' },
{
type: 'docsVersionDropdown',
// used for styling, see src/styles/theme/_navbar.css
className: 'navbar__link--version-dropdown',
},
{
href: 'https://github.com/wasmcloud/wasmcloud',
'aria-label': 'Star wasmCloud on GitHub',
position: 'right',
html: `<span class="badge badge--outline">Star us! ★ <github-count repo="wasmcloud/wasmcloud">1300</github-count></span>`,
className: 'sidebar-hidden',
},
await svgIconNavItem({
svgIconPath: './static/icons/github.svg',
label: 'GitHub',
href: 'https://github.com/wasmcloud/wasmcloud',
}),
await svgIconNavItem({
svgIconPath: './static/icons/slack.svg',
label: 'Slack',
href: 'https://slack.wasmcloud.com/',
}),
],
},
// announcementBar: {
// id: 'announcement',
// content: `📢 Announcement content goes here.`,
// },
footer: {
links: [
{
title: 'Community',
items: [
{
label: 'GitHub',
href: 'https://github.com/wasmcloud/',
},
{
label: 'Contributing',
href: 'https://github.com/wasmCloud/wasmCloud/blob/main/CONTRIBUTING.md',
},
{
label: 'Slack',
href: 'https://slack.wasmcloud.com',
},
{
label: 'Calendar & wasmCloud Wednesdays',
href: 'https://calendar.google.com/calendar/u/0/embed?src=c_6cm5hud8evuns4pe5ggu3h9qrs@group.calendar.google.com',
},
{
label: 'Community Meeting Notes',
to: '/community',
},
],
},
{
title: 'Social',
items: [
{
label: 'Twitter',
href: 'https://twitter.com/wasmcloud',
},
{
label: 'LinkedIn',
href: 'https://www.linkedin.com/company/wasmCloud/',
},
{
label: 'YouTube',
href: 'https://www.youtube.com/wasmcloud',
},
],
},
{
title: 'Organization',
items: [
{
href: 'https://ostif.org/ostif-has-completed-a-security-audit-of-wasmcloud/',
label: 'Security Assessment',
},
{
label: 'Privacy Policy',
to: '/privacy-policy',
},
{
label: 'Terms and Conditions',
to: '/terms-conditions',
},
{
label: 'Contact & Mailing List',
to: '/contact',
},
{
label: 'wasmCloud Swag',
to: '/swag',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} wasmCloud LLC. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Usage page: https://www.linuxfoundation.org/trademark-usage. Built with Docusaurus.`,
},
algolia: {
apiKey: 'f0ef30f3d98ce5e9a7dd7579bb221dfc',
indexName: 'wasmcloud',
appId: '2IM4TMH501',
},
} satisfies PresetClassicThemeConfig,
markdown: {
format: 'detect',
mdx1Compat: {
admonitions: false,
comments: false,
headingIds: false,
},
},
headTags: [
{
tagName: 'link',
attributes: { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
},
{
tagName: 'link',
attributes: {
rel: 'preconnect',
href: 'https://fonts.gstatic.com',
crossorigin: 'crossorigin',
},
},
{
tagName: 'link',
attributes: {
href: 'https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Lexend:wght@100..900&family=Inter:wght@100..900&display=swap',
rel: 'stylesheet',
},
},
],
onBrokenAnchors: 'throw',
onDuplicateRoutes: 'throw',
};
})();
/** @return {import('@docusaurus/types').Plugin} */
function customPostCssPlugin() {
return {
name: 'custom-postcss',
configurePostCss(options) {
options.plugins.push(require('postcss-preset-env'));
return options;
},
};
}
type NavbarItem = Required<Required<PresetClassicThemeConfig>['navbar']>['items'][number];
type SvgNavItemOptions = NavbarItem & {
svgIconPath: string;
label: string;
href: string;
className?: string;
position?: 'left' | 'right';
};
/**
* build an icon nav item, works with styles in `src/styles/theme/_navbar.css`
*/
async function svgIconNavItem({
svgIconPath,
label,
href,
className,
position = 'right',
...extras
}: SvgNavItemOptions): Promise<NavbarItem> {
const icon = await fs.readFile(svgIconPath, 'utf-8');
const linkClass = 'navbar__icon';
return {
href: href,
position,
html: `
${icon}
<span class="navbar__icon-label">${label}</span>
`,
className: `${className ? `${className} ` : ''}${linkClass}`,
...extras,
};
}
module.exports = config;