Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
447 lines (416 loc) · 14.9 KB
/
Copy pathdocusaurus.config.ts
File metadata and controls
447 lines (416 loc) · 14.9 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
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
import type * as Preset from "@docusaurus/preset-classic";
import type { Config, DocusaurusConfig, RouteConfig } from "@docusaurus/types";
import { themes } from "prism-react-renderer";
import { getRedirects } from "./redirects";
import { SKIP_IN_MARKDOWN_DOCS_CLASS } from "./src/lib/constants";
import { SCRIPT_WITH_CONSENT_TYPE } from "./src/lib/cookie-consent";
import {
getLatestDocCanonicalPath,
waspDslDocsVersions,
} from "./src/lib/old-docs-versions";
import cloudflareRedirects from "./src/plugins/cloudflare-redirects";
import { docusaurusPluginLlmFiles } from "./src/plugins/llm-files/docusaurus-plugin";
import autoImportTabs from "./src/remark/auto-import-tabs";
import autoJSCode from "./src/remark/auto-js-code";
import codeWithHole from "./src/remark/code-with-hole";
import fileExtSwitcher from "./src/remark/file-ext-switcher";
import fixAPILinks from "./src/remark/fix-api-links";
import searchAndReplace from "./src/remark/search-and-replace";
const lightCodeTheme = {
...themes.github,
plain: { ...themes.github.plain, backgroundColor: "var(--wasp-code-bg)" },
};
const darkCodeTheme = {
...themes.dracula,
plain: { ...themes.dracula.plain, backgroundColor: "var(--wasp-code-bg)" },
};
const includeCurrentVersion =
process.env.DOCS_INCLUDE_CURRENT_VERSION === "true";
const isProduction = process.env.NODE_ENV === "production";
const config: Config = {
title: "Wasp",
tagline:
"A simple language for developing full-stack web apps with less code.",
// url, baseUrl, organizationName, projectName and trailingSlash are set according to the
// instructions in https://docusaurus.io/docs/deployment#deploying-to-github-pages .
url: "https://wasp.sh",
baseUrl: "/", // Should be name of repo if hosted on Github Pages, but can be just '/' if custom domain is used.
organizationName: "wasp-lang", // Should be GitHub org/user name if hosted on Github Pages.
projectName: "wasp", // Should be repo name if hosted on Github Pages.
trailingSlash: false,
onBrokenLinks: "throw",
onBrokenAnchors: "throw",
favicon: "img/favicon.svg",
themeConfig: {
colorMode: {
respectPrefersColorScheme: true,
},
announcementBar: {
id: "wasp-100-typescript",
content:
'<a href="/blog/2026/06/15/wasp-typescript-spec" style="color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 12px;"><span style="font-weight: 400; text-transform: uppercase; letter-spacing: 0.1em;">Wasp is now 100% TypeScript</span><span style="display: inline-flex; align-items: center; border: 2px solid #111; background: #F5C842; color: #111; padding: 2px 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; font-size: 10px;">Meet TS Spec →</span></a>',
backgroundColor: "#3178C6",
textColor: "#FAFAFA",
isCloseable: false,
},
imageZoom: {
// Opt out any image with the `.no-default-zoom` class (used by our custom
// Carousel + ImgGallery components, which have their own lightbox).
selector: ".markdown img:not(.no-default-zoom)",
// Optional medium-zoom options
// see: https://www.npmjs.com/package/medium-zoom#options
options: {
// medium-zoom defaults to a white overlay, which shows through images
// with transparent backgrounds. The overlay lives on <body>, so a CSS
// variable resolves to the current theme's page background.
background: "var(--ifm-background-color)",
},
},
navbar: {
title: "Wasp",
logo: {
alt: "Wasp logo",
src: "img/wasp-logo.svg",
href: "/",
},
items: [
{
type: "docSidebar",
position: "left",
sidebarId: "docs",
label: "Docs",
className: "navbar-item-docs navbar-item-outside",
},
{
type: "docSidebar",
position: "left",
sidebarId: "api",
label: "API",
},
{
type: "docSidebar",
position: "left",
sidebarId: "guides",
label: "Guides",
},
{
type: "docsVersionDropdown",
position: "left",
className: "navbar-item-docs-version-dropdown",
},
{
to: "blog",
label: "Blog",
position: "left",
},
],
},
prism: {
additionalLanguages: [
"shell-session",
"haskell",
"markdown",
"diff",
"bash",
],
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
footer: {
style: "dark",
links: [
{
title: "Docs",
items: [
{
label: "Getting started",
to: "docs",
},
{
label: "Todo app tutorial",
to: "docs/tutorial/create",
},
],
},
{
title: "Community",
items: [
{
label: "Discord",
href: "https://discord.gg/rzdnErX",
},
],
},
{
title: "More",
items: [
{
label: "GitHub",
href: "https://github.com/wasp-lang/wasp",
},
{
label: "Contact",
to: "docs/contact",
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Wasp.`,
},
algolia: {
appId: "2EJBEYUJK0",
apiKey: "b90c50ab126398470abd0efa5d397870",
indexName: "wasp",
// ContextualSearch is useful when you are doing versioning,
// it searches only in v1 docs if you are searching from v1 docs.
// Therefore we have it enabled, since we have multiple doc versions.
contextualSearch: true,
},
image: "img/wasp_twitter_cover.png",
metadata: [
{ name: "twitter:card", content: "summary_large_image" },
{ property: "og:site_name", content: "Wasp" },
],
} as Preset.ThemeConfig,
presets: [
[
"@docusaurus/preset-classic",
{
docs: {
sidebarPath: "./sidebars.ts",
sidebarCollapsible: true,
editUrl: "https://github.com/wasp-lang/wasp/edit/release/web",
remarkPlugins: [
autoJSCode,
autoImportTabs,
fileExtSwitcher,
searchAndReplace,
codeWithHole,
fixAPILinks,
],
// ------ Configuration for multiple docs versions ------ //
// "current" docs (under /docs) are in-progress docs, so we show them only in development.
includeCurrentVersion,
// In development, we want "current" docs to be the default docs (served at /docs),
// to make it easier for us a bit. Otherwise, by default, the latest versioned docs
// will be served under /docs.
lastVersion: includeCurrentVersion ? "current" : undefined,
// Uncomment line below to build and show only current docs, for faster build times
// during development, if/when needed.
// onlyIncludeVersions: includeCurrentVersion ? ["current"] : undefined,
// "versions" option here enables us to customize each version of docs individually,
// and there are also other options if we ever need to customize versioned docs further.
versions: {
// We provide config for `current` only during development because otherwise
// we don't even build them (due to includeCurrentVersion above), so this config
// would cause error in that case.
...(includeCurrentVersion
? {
current: {
label: "Next", // Label shown in the documentation to address this version of docs.
noIndex: true, // these are un-released docs, we don't want search engines indexing them.
},
}
: {}),
...Object.fromEntries(
waspDslDocsVersions.map((version) => [
version,
{ noIndex: true },
]),
),
// Configuration example:
// "0.11.1": {
// path: "0.11.1", // default, but can be anything.
// label: "0.11.1", // default, but can be anything.
// banner: "unmaintained"
// // and more!
// },
},
// ------------------------------------------------------ //
},
blog: {
id: "blog",
path: "./blog",
routeBasePath: "blog",
blogTitle: "Wasp Blog: tutorials, updates and case studies",
blogDescription:
"The Wasp team writes tutorials, launch updates, case studies and engineering posts about Wasp and full-stack web development with React and Node.js.",
showReadingTime: true,
showLastUpdateTime: true,
blogSidebarCount: "ALL",
blogSidebarTitle: "All our posts",
postsPerPage: "ALL",
editUrl: "https://github.com/wasp-lang/wasp/edit/release/web",
onUntruncatedBlogPosts: "throw",
exclude: ["**/CLAUDE.md", "_wasp-intro.md"],
},
theme: {
customCss: ["./src/css/custom.css"],
},
sitemap: {
// A sitemap should list only canonical URLs, so we leave out the old
// docs pages that point their canonical URL to the latest docs.
async createSitemapItems({ defaultCreateSitemapItems, ...params }) {
const items = await defaultCreateSitemapItems(params);
// The routes list every page, also the `noindex` ones that have no
// sitemap entry (e.g. the docs writing guide).
const sitePaths = new Set(getRoutePaths(params.routes));
return items.filter((item) => {
const path = new URL(item.url).pathname;
const keepsOwnCanonicalUrl =
getLatestDocCanonicalPath(path, sitePaths) === undefined;
return keepsOwnCanonicalUrl;
});
},
},
} as Preset.Options,
],
],
scripts: getScripts(),
clientModules: ["./src/clientModules/track.ts"],
plugins: [
"plugin-image-zoom",
cloudflareRedirects({
redirects: getRedirects({
redirectCurrentVersionToCanonical: !includeCurrentVersion,
}),
}),
[
"@docusaurus/plugin-content-blog",
{
id: "resources",
path: "./resources",
routeBasePath: "resources",
blogTitle: "Wasp Resources: guides, comparisons and opinions",
blogDescription:
"Guides, comparisons, research and opinions on full-stack web frameworks, to help you pick and use the right one.",
authorsMapPath: "../blog/authors.yml",
showReadingTime: true,
showLastUpdateTime: true,
blogSidebarCount: "ALL",
blogSidebarTitle: "All resources",
postsPerPage: "ALL",
editUrl: "https://github.com/wasp-lang/wasp/edit/release/web",
onUntruncatedBlogPosts: "throw",
},
],
async function tailwindPlugin() {
return {
name: "docusaurus-tailwindcss",
configurePostCss(postcssOptions) {
// Appends TailwindCSS and AutoPrefixer.
postcssOptions.plugins.push(require("tailwindcss"));
postcssOptions.plugins.push(require("autoprefixer"));
return postcssOptions;
},
};
},
[
"docusaurus-plugin-typedoc",
{
// docusaurus-plugin-typedoc options
sidebar: { typescript: true },
// typedoc-plugin-markdown options
readme: "none", // Otherwise it will copy the `<repo>/README.md` file to the docs, which we don't want.
name: "API Reference", // The title of the index page.
router: "module",
// Shows each package's and module's description on the landing pages.
indexFormat: "table",
// Gives headings the same IDs that TypeDoc's links use. Otherwise
// Docusaurus generates its own, which don't always match, e.g. when
// two members share a name.
useCustomAnchors: true,
// Documents types that our packages reference but don't export, e.g.
// the `@wasp/lib-sdk-core` types used in the Wasp SDK's signatures. The
// theme plugin puts them in a "Referenced Types" group.
plugin: [
"typedoc-plugin-missing-exports",
"./src/plugins/typedoc-wasp-theme.ts",
],
theme: "wasp-markdown",
// input packages
entryPointStrategy: "packages",
entryPoints: ["../packages/spec", "./sdk-api-docs"],
// If you want to set an option to a specific package, you can create a
// `typedoc.jsonc` file in that package's folder with the desired
// options from
// https://typedoc.org/documents/Options.Package_Options.html.
},
],
docusaurusPluginLlmFiles({
skipElementInMarkdownDocsClass: SKIP_IN_MARKDOWN_DOCS_CLASS,
}),
],
themes: ["@docusaurus/theme-mermaid"],
markdown: {
mermaid: true,
mdx1Compat: {
admonitions: true,
comments: true,
headingIds: true,
},
hooks: {
onBrokenMarkdownLinks: "warn",
},
},
future: {
v4: true,
},
};
type DocusaurusScript = DocusaurusConfig["scripts"][number];
type ScriptWithConsent = Exclude<DocusaurusScript, string> & {
requiresConsent: boolean;
};
function getScripts() {
const sharedScripts: ScriptWithConsent[] = [
{
src: "/js/fix-multiple-trailing-slashes.js",
requiresConsent: false,
},
];
const devOnlyScripts: ScriptWithConsent[] = [];
const prodOnlyScripts: ScriptWithConsent[] = [
{
src: "/scripts/plausible-queue.js",
requiresConsent: false,
},
{
// We are using Cloudflare Workers to proxy the Plausible script.
src: "/waspara/wasp/script.js",
defer: true,
"data-domain": "wasp.sh",
"data-api": "/waspara/wasp/event",
// Plausible doesn't use cookies, so it can be loaded right away.
requiresConsent: false,
},
{
src: "/scripts/posthog.js",
defer: true,
requiresConsent: true,
},
];
const scripts = [
...sharedScripts,
...(isProduction ? prodOnlyScripts : devOnlyScripts),
];
return mapToDocusaurusScripts(scripts);
}
function mapToDocusaurusScripts(
scripts: ScriptWithConsent[],
): DocusaurusScript[] {
return scripts.map(({ requiresConsent, ...rest }) => ({
...rest,
// Scripts requiring consent shouldn't be loaded until the cookies are accepted,
// so we use a custom type on the script _not to load it_ automatically.
// Later, if cookies are accepted, the script will be loaded by the
// `src/components/CookieConsentBanner.tsx` component.
...(requiresConsent ? { type: SCRIPT_WITH_CONSENT_TYPE } : {}),
}));
}
function getRoutePaths(routes: RouteConfig[]): string[] {
return routes.flatMap((route) => [
route.path,
...getRoutePaths(route.routes ?? []),
]);
}
export default config;