Skip to content

Commit 5601b61

Browse files
committed
refactor: split docusaurus config in files
build: enable docusaurus "experimental_faster" build: enable docusaurus v4 features refactor: update autogen indexer tables refactor: use typescript for "redirects" refactor: various improvements style: fix indenting for code snippets
1 parent 1bf9cb0 commit 5601b61

File tree

18 files changed

+730
-539
lines changed

18 files changed

+730
-539
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# directories
22
.cache-loader
33
.docusaurus
4+
.repomix
45
build
56
node_modules
6-
repomix
77
src/autogen/**/*.mdx
88

99
# files

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"biome.enabled": true,
3+
"eslint.validate": ["md", "mdx"],
4+
"typescript.tsdk": "node_modules/typescript/lib",
35
"editor.codeActionsOnSave": {
46
"source.fixAll.biome": "explicit",
57
"source.organizeImports.biome": "explicit"
68
},
7-
"eslint.validate": ["md", "mdx"],
8-
"typescript.tsdk": "node_modules/typescript/lib",
99
"search.exclude": {
1010
".docusaurus": true,
1111
"build": true,

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

bun.lock

Lines changed: 281 additions & 8 deletions
Large diffs are not rendered by default.

cli/commands/autogen/indexers.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,59 +21,59 @@ export async function generateIndexers(options: CliOptions = {}): Promise<void>
2121
}
2222

2323
function generateTables(protocol: Indexer.Protocol, options: CliOptions): void {
24-
const graphTable = generateGraphTable(indexers.graph[protocol]);
2524
const envioTable = generateEnvioTable(indexers.envio[protocol]);
25+
const graphTable = generateGraphTable(indexers.graph[protocol]);
26+
27+
const envioFilePath = autogenFilePaths.envio(protocol);
28+
if (writeFileWithOverwrite({ content: envioTable, filePath: envioFilePath, options })) {
29+
console.log(`✔️ Generated ${_.capitalize(protocol)} endpoints table for Envio at: ${getRelative(envioFilePath)}`);
30+
}
2631

2732
const graphFilePath = autogenFilePaths.graph(protocol);
2833
if (writeFileWithOverwrite({ content: graphTable, filePath: graphFilePath, options })) {
2934
console.log(
3035
`✔️ Generated ${_.capitalize(protocol)} endpoints table for The Graph at: ${getRelative(graphFilePath)}`,
3136
);
3237
}
33-
34-
const envioFilePath = autogenFilePaths.envio(protocol);
35-
if (writeFileWithOverwrite({ content: envioTable, filePath: envioFilePath, options })) {
36-
console.log(`✔️ Generated ${_.capitalize(protocol)} endpoints table for Envio at: ${getRelative(envioFilePath)}`);
37-
}
3838
}
3939

40-
function generateGraphTable(indexers: Indexer[]): string {
41-
let markdown = `| Chain | Production URL | Testing URL | Explorer URL |\n`;
40+
function generateEnvioTable(indexers: Indexer[]): string {
41+
let markdown = `| Chain | Production URL | Playground URL | Explorer URL |\n`;
4242
markdown += `| -------- | -------------- | ----------- | ------------ |\n`;
4343

4444
for (const indexer of indexers) {
45-
const chain = sablier.chains.getOrThrow(indexer.chainId);
45+
const chain = sablier.chains.get(indexer.chainId);
46+
if (!chain || !chain.name) {
47+
continue;
48+
}
4649

4750
const productionURL = indexer.endpoint.url;
48-
const testingURL = indexer.testingURL;
51+
const playgroundURL = indexer.testingURL;
4952
const explorerURL = indexer.explorerURL;
5053

51-
const productionCell = `[${indexer.name}](${productionURL})`;
52-
const testingCell = testingURL ? `[Testing](${testingURL})` : "N/A";
54+
const productionCell = `${productionURL}`;
55+
const playgroundCell = playgroundURL ? `[Playground](${playgroundURL})` : "N/A";
5356
const explorerCell = explorerURL ? `[Explorer](${explorerURL})` : "N/A";
5457

55-
markdown += `| ${chain.name} | ${productionCell} | ${testingCell} | ${explorerCell} |\n`;
58+
markdown += `| ${chain.name} | ${productionCell} | ${playgroundCell} | ${explorerCell} |\n`;
5659
}
5760

5861
return markdown;
5962
}
6063

61-
function generateEnvioTable(indexers: Indexer[]): string {
64+
function generateGraphTable(indexers: Indexer[]): string {
6265
let markdown = `| Chain | Production URL | Testing URL | Explorer URL |\n`;
6366
markdown += `| -------- | -------------- | ----------- | ------------ |\n`;
6467

6568
for (const indexer of indexers) {
66-
const chain = sablier.chains.get(indexer.chainId);
67-
if (!chain || !chain.name) {
68-
continue;
69-
}
69+
const chain = sablier.chains.getOrThrow(indexer.chainId);
7070

7171
const productionURL = indexer.endpoint.url;
7272
const testingURL = indexer.testingURL;
7373
const explorerURL = indexer.explorerURL;
7474

75-
const productionCell = `${productionURL}`;
76-
const testingCell = `[Testing](${testingURL})`;
75+
const productionCell = `[${indexer.name}](${productionURL})`;
76+
const testingCell = testingURL ? `[Testing](${testingURL})` : "N/A";
7777
const explorerCell = explorerURL ? `[Explorer](${explorerURL})` : "N/A";
7878

7979
markdown += `| ${chain.name} | ${productionCell} | ${testingCell} | ${explorerCell} |\n`;

config/plugins.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { Options as ClientRedirectsOptions } from "@docusaurus/plugin-client-redirects";
2+
import type { Options as VercelAnalyticsOptions } from "@docusaurus/plugin-vercel-analytics";
3+
import { type DocusaurusConfig } from "@docusaurus/types";
4+
import { createRedirects, redirects } from "./redirects";
5+
6+
const clientRedirects: [string, ClientRedirectsOptions] = [
7+
"@docusaurus/plugin-client-redirects",
8+
{
9+
createRedirects,
10+
id: "default",
11+
redirects: redirects,
12+
},
13+
];
14+
15+
const vercelAnalytics: [string, VercelAnalyticsOptions] = [
16+
"vercel-analytics",
17+
{
18+
mode: "auto",
19+
},
20+
];
21+
22+
export const plugins: DocusaurusConfig["plugins"] = [clientRedirects, vercelAnalytics];

config/presets.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type * as Preset from "@docusaurus/preset-classic";
2+
import type { DocusaurusConfig } from "@docusaurus/types";
3+
import rehypeKatex from "rehype-katex";
4+
import remarkGfm from "remark-gfm";
5+
import remarkMath from "remark-math";
6+
7+
const classic: [string, Preset.Options] = [
8+
"classic",
9+
{
10+
docs: {
11+
editUrl: "https://github.com/sablier-labs/docs/blob/main/",
12+
rehypePlugins: [rehypeKatex],
13+
remarkPlugins: [remarkGfm, remarkMath],
14+
routeBasePath: "/", // Serve the docs at the site's root
15+
sidebarPath: "./config/sidebars.ts",
16+
},
17+
theme: {
18+
customCss: ["./src/css/sablier.css", "./src/css/custom.css"],
19+
},
20+
},
21+
];
22+
23+
export const presets: DocusaurusConfig["presets"] = [classic];

config/redirects.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import type { RedirectOption } from "@docusaurus/plugin-client-redirects/lib/options";
2+
3+
function redirect(from: string, to: string): RedirectOption {
4+
return { from, to };
5+
}
6+
7+
/**
8+
* The slugs and IDs used in the Docusaurus site have evolved over time.
9+
* This file contains the redirects for the old slugs and IDs to the new ones.
10+
*/
11+
export const redirects: RedirectOption[] = [
12+
/* -------------------------------------------------------------------------- */
13+
/* AIRDROPS */
14+
/* -------------------------------------------------------------------------- */
15+
redirect("/concepts/merkle-airdrops", "/concepts/airdrops"),
16+
/* -------------------------------------------------------------------------- */
17+
/* API */
18+
/* -------------------------------------------------------------------------- */
19+
redirect("/api", "/api/overview"),
20+
// TODO: change this to the new GraphQL section
21+
redirect("/api/airdrops/the-graph", "/api/overview"),
22+
redirect("/api/indexers/protocol", "/api/overview"),
23+
redirect("/api/lockup/the-graph", "/api/overview"),
24+
redirect("/api/merkle-api/intro", "/api/airdrops/merkle-api/overview"),
25+
redirect("/api/subgraphs/endpoints", "/api/lockup/indexers"),
26+
redirect("/api/subgraphs/merkle", "/api/overview"),
27+
redirect("/api/subgraphs/overview", "/api/overview"),
28+
redirect("/api/subgraphs/protocol", "/api/overview"),
29+
/* -------------------------------------------------------------------------- */
30+
/* APPS */
31+
/* -------------------------------------------------------------------------- */
32+
redirect("/apps", "/apps/features/overview"),
33+
redirect("/apps/csv-support", "/apps/guides/csv-support"),
34+
redirect("/apps/features", "/apps/features/vesting"),
35+
redirect("/apps/features/airstreams", "/apps/features/airdrops"),
36+
redirect("/apps/features/general", "/apps/features/overview"),
37+
redirect("/apps/features/streams", "/apps/features/vesting"),
38+
redirect("/apps/overview", "/apps/features/overview"),
39+
redirect("/apps/support/how-to", "/support/how-to"),
40+
redirect("/apps/url-schemes", "/apps/guides/url-schemes"),
41+
/* -------------------------------------------------------------------------- */
42+
/* INDEXERS */
43+
/* -------------------------------------------------------------------------- */
44+
redirect("/api/airdrops/endpoints", "/api/airdrops/indexers"),
45+
redirect("/api/flow/endpoints", "/api/flow/indexers"),
46+
redirect("/api/lockup/endpoints", "/api/lockup/indexers"),
47+
/* -------------------------------------------------------------------------- */
48+
/* LEGACY: 2019-2021 */
49+
/* -------------------------------------------------------------------------- */
50+
redirect("/protocol/faq/basics", "/concepts/what-is-sablier"),
51+
redirect("/protocol/guides/chains", "/guides/legacy/overview"),
52+
redirect("/protocol/guides/getting-started", "/guides/legacy/overview"),
53+
redirect("/protocol/introduction", "/concepts/what-is-sablier"),
54+
redirect("/protocol/subgraphs/endpoints", "/api/overview"),
55+
redirect("/contracts/v1/deployments", "/guides/legacy/deployments"),
56+
redirect("/contracts/v1/guides/getting-started", "/guides/legacy/overview"),
57+
redirect("/contracts/v1/overview", "/guides/legacy/overview"),
58+
/* -------------------------------------------------------------------------- */
59+
/* LOCKUP: 2024 and Earlier */
60+
/* -------------------------------------------------------------------------- */
61+
redirect("/concepts/protocol/fees", "/concepts/fees"),
62+
redirect("/concepts/protocol/nft", "/concepts/nft"),
63+
redirect("/concepts/protocol/stream-types", "/concepts/lockup/stream-shapes"),
64+
redirect("/concepts/protocol/streaming", "/concepts/streaming"),
65+
redirect("/concepts/protocol/transferability", "/concepts/transferability"),
66+
redirect("/concepts/sablier-protocol", "/concepts/what-is-sablier"),
67+
redirect("/contracts/v2/deployments/v2.0", "/guides/lockup/previous-deployments/v1.0"),
68+
redirect("/contracts/v2/deployments/v2.1", "/guides/lockup/previous-deployments/v1.1"),
69+
redirect("/contracts/v2/guides", "/guides/lockup/overview"),
70+
redirect("/contracts/v2/reference/overview", "/reference/overview"),
71+
redirect("/contracts/v2/security", "/concepts/security"),
72+
redirect("/csv", "/apps/guides/csv-support"),
73+
];
74+
75+
export function createRedirects(existingPath: string) {
76+
const redirects = [];
77+
// Redirect /concepts/protocol/** to /concepts/lockup/**
78+
if (existingPath.startsWith("/concepts/lockup/")) {
79+
redirects.push(existingPath.replace("/concepts/lockup/", "/concepts/protocol/"));
80+
}
81+
// Redirect /contracts/v1/guides/** to /guides/legacy/**
82+
else if (existingPath.startsWith("/guides/legacy/")) {
83+
redirects.push(existingPath.replace("/guides/legacy/", "/contracts/v1/guides/"));
84+
}
85+
// Redirect /contracts/v2/reference/** to /reference/lockup/**
86+
else if (existingPath.startsWith("/reference/lockup/")) {
87+
redirects.push(existingPath.replace("/reference/lockup/", "/contracts/v2/reference/"));
88+
}
89+
// Redirect /contracts/v1/** to /reference/legacy/**
90+
else if (existingPath.startsWith("/reference/legacy/")) {
91+
redirects.push(existingPath.replace("/reference/legacy/", "/contracts/v1/"));
92+
}
93+
// Redirect /contracts/v2/guides/** to /guides/lockup/examples/**
94+
else if (existingPath.startsWith("/guides/lockup/examples/")) {
95+
redirects.push(existingPath.replace("/guides/lockup/examples/", "/contracts/v2/guides/"));
96+
}
97+
98+
return redirects;
99+
}

sidebars.js renamed to config/sidebars.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
2-
// By default, Docusaurus generates a sidebar from the docs folder structure,
3-
// but we can customize it to include only the desired sections.
4-
const sidebars = {
1+
import type { SidebarsConfig } from "@docusaurus/plugin-content-docs";
2+
3+
/**
4+
* By default, Docusaurus generates a sidebar from the docs folder structure, but we can
5+
* customize it to include only the desired sections.
6+
*/
7+
const sidebars: SidebarsConfig = {
58
apiSidebar: [{ dirName: "api", type: "autogenerated" }],
69
appSidebar: [{ dirName: "apps", type: "autogenerated" }],
710
conceptsSidebar: [{ dirName: "concepts", type: "autogenerated" }],

0 commit comments

Comments
 (0)