Repository navigation
Expand file tree
/
Copy pathdocusaurus.config.js
More file actions
343 lines (326 loc) · 12.1 KB
/
Copy pathdocusaurus.config.js
File metadata and controls
343 lines (326 loc) · 12.1 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
/* eslint-disable */
const { themes: prismThemes } = require('prism-react-renderer');
const lightCodeTheme = prismThemes.github;
const darkCodeTheme = prismThemes.vsDark;
const { webpackPlugin } = require('./plugins/webpack-plugin.cjs');
// remark/rehype plugins are ESM-only as of MDX 3 / Docusaurus 3. Under the
// sync (jiti) config loader, `require()` returns the module namespace object,
// so unwrap the default export before handing the plugin to unified.
const esmDefault = (m) => m.default ?? m;
const npm2yarn = esmDefault(require('@docusaurus/remark-plugin-npm2yarn'));
const remarkMath = esmDefault(require('remark-math'));
const rehypeKatex = esmDefault(require('rehype-katex'));
// Minimal .env loader (Docusaurus does not read .env, and we avoid adding a
// dotenv dependency just for one var). Only fills vars not already set, so the
// real process environment (Workers Builds, CI) always wins over the file.
(() => {
try {
const fs = require('fs');
const path = require('path');
const envPath = path.join(__dirname, '.env');
if (!fs.existsSync(envPath)) return;
for (const line of fs.readFileSync(envPath, 'utf8').split('\n')) {
const m = line.match(/^\s*([\w.-]+)\s*=\s*(.*)\s*$/);
if (!m || line.trimStart().startsWith('#')) continue;
const key = m[1];
let val = m[2].replace(/^["']|["']$/g, '');
if (process.env[key] === undefined) process.env[key] = val;
}
} catch {
/* best-effort; real env vars still apply */
}
})();
// Algolia DocSearch search-only API key. This key is public by design (it must
// ship to the browser for the search box to work) and is read-only
// (search/listIndexes/settings/browse; no write/admin ACL). It is read from an
// env var rather than committed inline so org secret scanners stop flagging it
// as an exposed credential; env-injecting it changes nothing about security.
// Set ALGOLIA_SEARCH_KEY in the Cloudflare Workers Builds variables and in a
// local `.env`.
// The scraper's write credentials (APPLICATION_ID / API_KEY) are separate
// GitHub Action secrets and are correctly not in this repo.
const ALGOLIA_SEARCH_KEY = process.env.ALGOLIA_SEARCH_KEY;
if (!ALGOLIA_SEARCH_KEY) {
throw new Error(
'ALGOLIA_SEARCH_KEY is not set. Set it (Workers Builds variables, or a local .env) ' +
'so the docs search box works. It is the public search-only DocSearch key, ' +
'not a secret; see docusaurus.config.js for details.'
);
}
/** @type {import('@docusaurus/preset-classic').Options} */ defaultSettings = {
remarkPlugins: [[npm2yarn, { sync: true }]],
};
// Math (KaTeX) is applied globally to the single docs instance. remark-math 6
// supports `singleDollarTextMath: false`, which requires `$$...$$` for inline
// math and leaves a single `$` as literal text, so bare dollar signs in prose
// and code (currency like $500, shell vars like $HOME / $CODE_ID across the
// cosmwasm and validate pages) are NOT parsed as math. This removes the old
// per-section scoping (a remark-math v3 limitation) that previously forced the
// docs to be split into separate plugin instances. Inline math uses `$$...$$`
// on the same line; display math uses `$$...$$` as its own block.
const mathRemark = [remarkMath, { singleDollarTextMath: false }];
// Single docs instance rooted at `docs/`, served at the site root so existing
// URLs are preserved (docs/osmosis-core/... -> /osmosis-core/...). One sidebar
// follows the reader across all sections (the fix for the former per-section
// isolated sidebars). This is the collapse-only step; the folder->taxonomy
// reorganization and redirects come in a later phase.
const docsPlugin = [
'@docusaurus/plugin-content-docs',
/** @type {import('@docusaurus/plugin-content-docs').Options} */
({
path: 'docs',
routeBasePath: '/',
id: 'default',
sidebarPath: require.resolve('./sidebars-default.js'),
breadcrumbs: false,
editUrl: 'https://github.com/osmosis-labs/docs/tree/main/',
remarkPlugins: [...defaultSettings.remarkPlugins, mathRemark],
rehypePlugins: [rehypeKatex],
}),
];
// In-repo backstop for the URL changes from the IA restructure.
// The Worker serves the canonical 308s (static/_redirects), but this client
// redirect keeps old paths resolving on local builds, where those rules do not
// apply. The full old->new map is generated from the page move plan.
const redirectsPlugin = [
'@docusaurus/plugin-client-redirects',
/** @type {import('@docusaurus/plugin-client-redirects').Options} */
({
redirects: require('./redirects.json'),
}),
];
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Osmosis Docs',
tagline: 'Build on the leading decentralized Cosmos exchange. 🚀',
// TODO: Update base url
url: 'https://docs.osmosis.zone',
baseUrl: '/',
onBrokenLinks: 'throw',
// Anchors throw so a genuinely broken in-page link fails the build rather than
// scrolling past in the log. The /api reference page uses Stoplight Elements with
// hash routing, and those fragments cannot be verified statically, so links into
// it are written without a fragment instead of being exempted wholesale.
onBrokenAnchors: 'throw',
markdown: {
hooks: {
onBrokenMarkdownLinks: 'throw',
},
},
favicon: '/favicon.png',
trailingSlash: false,
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'osmosis-labs', // Usually your GitHub org/user name.
projectName: 'docs', // Usually your repo name.
// 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',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: false,
blog: false,
theme: {
customCss: [
require.resolve('./src/css/custom.css'),
require.resolve('./src/css/api-reference.css'),
],
},
}),
],
],
plugins: [
docsPlugin,
redirectsPlugin,
webpackPlugin,
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
image: '/img/osmosis-docs-card.png',
colorMode: {
defaultMode: 'dark',
},
docs: {
sidebar: {
hideable: true,
},
},
navbar: {
// NOTE: hideOnScroll breaks on `/api`, enable when fixed
// hideOnScroll: true,
logo: {
href: '/',
src: '/logo/light.svg',
srcDark: '/logo/dark.svg',
alt: 'Osmosis Docs',
height: '26px',
width: '114px',
},
items: [
{
label: 'Learn',
to: 'learn',
position: 'left',
},
{
label: 'Integrate',
to: 'integrate',
position: 'left',
},
{
label: 'Build',
position: 'left',
items: [
{ label: 'Developer Environment', to: 'build/developer-environment' },
{ label: 'Chain Development', to: 'build/chain' },
{ label: 'CosmWasm', to: 'build/cosmwasm' },
{ label: 'Frontend & SDKs', to: 'build/frontend' },
],
},
{
label: 'Validate',
to: 'validate',
position: 'left',
},
{
label: 'Community',
to: 'community',
position: 'left',
},
{
href: 'https://github.com/osmosis-labs',
className: 'pseudo-icon github-icon',
position: 'right',
},
{
href: 'https://discord.com/invite/osmosis',
className: 'pseudo-icon discord-icon',
position: 'right',
},
{
type: 'search',
position: 'right',
},
{
label: 'Launch Dex',
href: 'https://app.osmosis.zone',
position: 'right',
className: 'dev-portal-signup dev-portal-link',
},
],
},
footer: {
logo: {
href: '/',
src: '/logo/light.svg',
srcDark: '/logo/dark.svg',
alt: 'Osmosis Docs',
height: '36px',
},
links: [
{
title: 'Platform',
items: [
{ label: 'Trade', href: 'https://app.osmosis.zone' },
{ label: 'Assets', href: 'https://app.osmosis.zone/assets' },
{ label: 'Staking', href: 'https://app.osmosis.zone/stake' },
{ label: 'Pools', href: 'https://app.osmosis.zone/pools' },
],
},
{
title: 'Token',
items: [
{ label: 'OSMO', href: 'https://app.osmosis.zone/assets/OSMO' },
{ label: 'CoinGecko', href: 'https://www.coingecko.com/en/coins/osmosis' },
{ label: 'CoinMarketCap', href: 'https://coinmarketcap.com/currencies/osmosis/' },
{ label: 'Governance', href: 'https://support.osmosis.zone/tutorials/governance' },
{ label: 'Vote', href: 'https://daodao.zone/gov/osmosis/proposals' },
],
},
{
title: 'Community',
items: [
{ label: 'X (Twitter)', href: 'https://twitter.com/osmosis' },
{ label: 'Telegram', href: 'https://t.me/osmosis_chat' },
{ label: 'Discord', href: 'https://discord.com/invite/osmosis' },
{ label: 'Forum', href: 'https://forum.osmosis.zone/' },
],
},
{
title: 'Developers',
items: [
{ label: 'Docs', href: 'https://docs.osmosis.zone/' },
{ label: 'GitHub', href: 'https://github.com/osmosis-labs' },
{ label: 'Grants', href: 'https://grants.osmosis.zone/' },
],
},
{
title: 'Team',
items: [
{ label: 'Contact', href: 'https://support.osmosis.zone/' },
{ label: 'Blog', href: 'https://forum.osmosis.zone/c/blog/13' },
],
},
],
copyright: 'Copyright © Osmosis Labs since 2023. All rights reserved.',
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: [
'dart',
'ruby',
'groovy',
'kotlin',
'java',
'swift',
'objectivec',
'rust',
'toml',
],
},
algolia: {
// Org-owned Algolia account. The docsearch-scraper GitHub Action
// (APPLICATION_ID / API_KEY secrets) populates the `Docs` index.
// apiKey is the public search-only key, read from ALGOLIA_SEARCH_KEY
// (see the const near the top of this file).
appId: 'F26GLV8TNU',
apiKey: ALGOLIA_SEARCH_KEY,
indexName: 'Docs',
// Kept off through the single-instance migration: the new index
// has faceting configured, but page `docusaurus_tag` values will flip
// from per-section to `docs-default-current` on that merge and lag the
// index by one crawl. Re-enable once the structure has settled.
contextualSearch: false,
// Send click/conversion events to the Algolia Insights API so the
// dashboard can report which results users actually open. DocSearch
// emits these itself; the dashboard's "automatic events collection"
// toggle does not apply (it targets raw InstantSearch/Autocomplete).
insights: true,
searchParameters: {},
},
}),
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-n8MVd4RsNIU0tAv4ct0nTaAbDJwPJzDEaqSD1odI+WdtXRGWt2kTvGFasHpSy3SV',
crossorigin: 'anonymous',
},
// Poppins for headings (Inter remains for body, Fira Code for mono).
{
href: 'https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&display=swap',
type: 'text/css',
},
],
};
module.exports = config;