-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathdocusaurus.config.ts
More file actions
399 lines (362 loc) · 15.7 KB
/
docusaurus.config.ts
File metadata and controls
399 lines (362 loc) · 15.7 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
import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';
import variablePlaceholder from './src/plugins/variable-placeholder';
import llmsTxtGenerator from './src/plugins/llms-txt-generator';
import versionNoindex from './src/plugins/version-noindex';
import robotsTxtGenerator from './src/plugins/robots-txt-generator';
import faqSchema from './src/plugins/faq-schema';
import { resolveLastmod } from './src/plugins/sitemap-lastmod';
import versions from './versions.json';
// Prism theme: our light mode uses a dark code-block background.
// Use a dark token palette (dracula) to keep contrast, and only override plain bg/fg.
const greptimePrismLightTheme = {
...prismThemes.dracula,
plain: {
...prismThemes.dracula.plain,
backgroundColor: '#473460',
color: '#ffffff',
},
};
const greptimePrismDarkTheme = {
...prismThemes.dracula,
plain: {
...prismThemes.dracula.plain,
backgroundColor: '#2d1f3a',
color: '#ffffff',
},
};
const locale = process.env.DOC_LANG || 'en';
const biel_project_id = process.env.BIEL_PROJECT_ID;
// Shared between docs preset and llms plugin to keep exclusions in sync
const docsExcludePatterns = [
'db-cloud-shared/**',
'user-guide/client-libraries/template.md',
'getting-started/quick-start/quick-start-template.md',
'**/template.md',
'user-guide/python-scripts/**',
'user-guide/ingest-data/for-iot/grpc-sdks/template.md',
'contributor-guide/datanode/python-scripts.md',
];
// For versioning commands, we need all locales available
// For building, we only need the current locale
const isVersioningCommand = process.argv.some(arg =>
arg.includes('docs:version') || arg.includes('write-translations')
);
const availableLocales = isVersioningCommand ? ['en', 'zh'] : [locale];
// Get the latest version (first item in versions array)
const latestVersion = versions[0];
const latestVersionNumber = parseFloat(latestVersion);
const metaMap = {
'en': [
{ name: 'keywords', content: 'time series database, open source time series database, time series data, observability database, open source observability database, observability tools, cloud native database, data observability, observability platform, edge database, IoT edge computing, edge cloud computing, log management, log aggregation, high cardinality, sql query examples, opentelemetry collector, GreptimeDB, opentelemetry, Greptime, open source database, log storage, traces storage, metrics, rust database, OpenTelemetry database' },
{ name: 'description', content: 'GreptimeDB is a cloud-native, real-time observability database for metrics, logs, and traces. Learn how to gain fast, cost-efficient insights at any scale from edge to cloud with GreptimeDB and GreptimeCloud.' },
{ property: 'og:type', content: 'website' },
{ property: 'og:image', content: 'https://greptime.com/resource/greptime_home_thumbnail.png' },
{ property: 'og:title', content: 'GreptimeDB Documentation | Unified observability database' },
{ property: 'og:description', content: 'Discover how GreptimeDB unifies metrics, logs, and traces with SQL and PromQL. Fast, Efficient, and Real-Time.' },
{ property: 'twitter:card', content: 'summary_large_image' },
{ property: 'twitter:image', content: 'https://greptime.com/resource/greptime_home_thumbnail.png' },
{ name: 'msvalidate.01', content: 'BD813946F80D5B50E162932BF3FD0D49' }
],
'zh': [
{ name: 'keywords', content: '时序数据库, 开源时序数据库, 时序数据, 可观测数据,可观测性数据库,可观测性工具, 云原生数据库, 数据可观测性, 可观测性平台, 边缘数据库, 物联网边缘计算, 边缘云计算, 日志管理, 日志聚合, 日志存储, 链路存储, PromQL 存储, 高基数, SQL查询示例, OpenTelemetry, OpenTelemetry 收集器, GreptimeDB, Greptime, Rust 数据库, 开源数据库, OpenTelemetry 数据库' },
{ name: 'description', content: 'GreptimeDB 是一款云原生的实时可观测性数据库,统一处理指标、日志和链路追踪数据。通过 GreptimeDB 和 GreptimeCloud,您可以在从边缘到云的任意规模下,实现快速且高性价比的数据洞察。' },
{ property: 'og:type', content: 'website' },
// og:url and twitter:url are intentionally omitted so Docusaurus
// infers the correct per-page absolute URL from siteConfig.url
// (i.e. https://docs.greptime.cn/... when building zh locale).
{ property: 'og:image', content: 'https://greptime.com/resource/greptime_home_thumbnail.png' },
{ property: 'og:title', content: 'GreptimeDB 文档 | 可观测性数据库' },
{ property: 'og:description', content: '了解 GreptimeDB 如何通过 SQL 和 PromQL 统一处理指标、日志和链路追踪。快速、高效、实时。' },
{ property: 'twitter:card', content: 'summary_large_image' },
{ property: 'twitter:image', content: 'https://greptime.com/resource/greptime_home_thumbnail.png' },
{ name: 'msvalidate.01', content: 'BD813946F80D5B50E162932BF3FD0D49' }
]
};
/** Pin biel-search CDN — @latest can introduce WS protocol regressions (e.g. isPartial on undefined). */
const BIEL_SEARCH_VERSION = '0.1.65';
const bielMetaMap = {
'en': {
project: biel_project_id,
headerTitle: 'Greptime AI',
bielButtonText: "Ask AI",
version: BIEL_SEARCH_VERSION,
buttonStyle: 'dark',
sourcesText: 'Related Documents',
inputPlaceholderText: 'Ask a question about Greptime...',
footerText: 'AI-generated answers may contain errors. <br> You can also communicate with engineers through <b><a href="https://github.com/orgs/GreptimeTeam/discussions">Github Discussions</a></b> or join <a href="https://greptime.com/slack">Slack community</a>.',
welcomeMessage: 'Hi! I am Greptime AI. You can ask me questions about GreptimeDB. For example, I can help you write SQL, Pipelines, or other GreptimeDB-related code.'
},
'zh': {
project: biel_project_id,
headerTitle: 'Greptime AI',
bielButtonText: "向 AI 提问",
version: BIEL_SEARCH_VERSION,
buttonStyle: 'dark',
sourcesText: '相关文档',
inputPlaceholderText: '请输入和 Greptime 相关的问题...',
footerText: 'AI 生成的答案可能包含错误。<br> 你还可以通过 <b><a href="https://github.com/orgs/GreptimeTeam/discussions">Github Discussions</a></b> 或加入 <a href="https://greptime.com/slack">Slack 社区</a>与工程师沟通。',
welcomeMessage: '你好,我是 Greptime AI。你可以问我关于 GreptimeDB 的问题,例如我可以帮助你编写 SQL、Pipeline 或其他与 GreptimeDB 相关的代码。',
}
};
const titleMap = {
'en': 'GreptimeDB Documentation',
'zh': 'GreptimeDB 文档'
};
// Preconnect / dns-prefetch hints: give the browser a head start on the
// handful of cross-origin domains every page hits. Algolia DocSearch
// registers its own preconnect automatically, so we don't duplicate it.
const preconnectHintsMap = {
'en': [
{ tagName: 'link', attributes: { rel: 'preconnect', href: 'https://www.googletagmanager.com', crossorigin: 'anonymous' } },
{ tagName: 'link', attributes: { rel: 'preconnect', href: 'https://cdn.jsdelivr.net', crossorigin: 'anonymous' } },
{ tagName: 'link', attributes: { rel: 'dns-prefetch', href: 'https://greptime.com' } },
],
'zh': [
{ tagName: 'link', attributes: { rel: 'preconnect', href: 'https://hm.baidu.com', crossorigin: 'anonymous' } },
{ tagName: 'link', attributes: { rel: 'preconnect', href: 'https://cdn.jsdelivr.net', crossorigin: 'anonymous' } },
{ tagName: 'link', attributes: { rel: 'dns-prefetch', href: 'https://greptime.cn' } },
],
};
const taglineMap = {
'en': 'The open-source observability database for metrics, logs, traces, and wide events.',
'zh': '为指标、日志、链路和宽事件打造的开源可观测性数据库。'
};
const hostMap = {
'en': 'https://greptime.com',
'zh': 'https://greptime.cn'
};
const urlMap = {
'en': 'https://docs.greptime.com',
'zh': 'https://docs.greptime.cn'
};
const algoliaMap = {
'en': {
// The application ID provided by Algolia
appId: 'SRGB68Y6CW',
// Public API key: it is safe to commit it
apiKey: 'eacb3d367f08bb200e8dbfc2470984d8',
indexName: 'greptime',
// Optional: see doc section below
contextualSearch: true,
// Optional: Algolia search parameters
searchParameters: {},
// Optional: path for search page that enabled by default (`false` to disable it)
searchPagePath: 'search',
// Optional: whether the insights feature is enabled or not on Docsearch (`false` by default)
insights: false,
},
'zh': {
// The application ID provided by Algolia
appId: 'SCVT6GSUZV',
// Public API key: it is safe to commit it
apiKey: '450bf5e5a3c1ecd3c4154530e25678c5',
indexName: 'greptime',
// Optional: see doc section below
contextualSearch: true,
// Optional: Algolia search parameters
searchParameters: {},
// Optional: path for search page that enabled by default (`false` to disable it)
searchPagePath: 'search',
// Optional: whether the insights feature is enabled or not on Docsearch (`false` by default)
insights: false,
}
};
const config: Config = {
title: titleMap[locale],
tagline: taglineMap[locale],
favicon: '/favicon.ico',
headTags: preconnectHintsMap[locale],
// Set the production url of your site here
url: urlMap[locale],
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'greptime', // Usually your GitHub org/user name.
projectName: 'docs', // Usually your repo name.
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
onBrokenAnchors: "ignore",
// Even if you don't use internationalization, 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: locale,
locales: availableLocales, // All locales for versioning, current locale for building
},
presets: [
[
'classic',
{
docs: {
sidebarPath: './sidebars.ts',
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl: ({ locale, version, versionDocsDirPath, docPath }) => {
if (locale === 'zh') {
// Chinese locale: i18n folder, versioned by current|version-<x>
const versionDir = version === 'current' ? 'current' : `version-${version}`;
return `https://github.com/GreptimeTeam/docs/edit/main/i18n/zh/docusaurus-plugin-content-docs/${versionDir}/${docPath}`;
}
// English locale: use Docusaurus-provided versionDocsDirPath
return `https://github.com/GreptimeTeam/docs/edit/main/${versionDocsDirPath}/${docPath}`;
},
routeBasePath: '/',
exclude: docsExcludePatterns,
showLastUpdateTime: true,
versions: {
current: {
label: 'Nightly',
path: 'nightly',
}
},
remarkPlugins: [
[variablePlaceholder, {}]
]
},
blog: {
showReadingTime: true,
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl:
'https://github.com/GreptimeTeam/blog/',
routeBasePath: 'release-notes',
blogSidebarCount: 'ALL',
blogSidebarTitle: 'Release Notes'
},
theme: {
customCss: [
'./src/css/greptime-tokens.css',
'./src/css/custom.css',
],
},
gtag: {
trackingID: 'G-BYNN8J57JZ',
anonymizeIP: false,
},
sitemap: {
priority: 0.8,
// Only index the latest stable version. Nightly and historical
// versions are noindex'd by src/plugins/version-noindex.ts and
// must also be excluded from the sitemap to avoid sending Google
// contradictory signals (sitemap "please index" vs meta "noindex").
createSitemapItems: async (params) => {
const { defaultCreateSitemapItems, ...rest } = params;
const items = await defaultCreateSitemapItems(rest);
const historicalPrefixes = versions.slice(1).map(v => `/${v}/`);
const excludedPrefixes = ['/nightly/', ...historicalPrefixes];
const sitemapLocale = (locale === 'zh' ? 'zh' : 'en') as 'en' | 'zh';
return items
.filter((item) => {
const pathname = new URL(item.url).pathname;
return !excludedPrefixes.some(prefix => pathname.startsWith(prefix));
})
.map((item) => {
// Attach git mtime as <lastmod> so Google gets a real
// freshness signal. Release-notes and other non-doc URLs
// that can't be mapped keep the default (no lastmod).
const lastmod = resolveLastmod(item.url, sitemapLocale, latestVersion);
return lastmod ? { ...item, lastmod } : item;
});
},
},
} satisfies Preset.Options,
],
],
trailingSlash: true,
plugins: [
// Only load docusaurus-biel plugin if biel_project_id is defined
...(biel_project_id ? [['docusaurus-biel', bielMetaMap[locale]]] : []),
[llmsTxtGenerator, {
ignoreFiles: [
...docsExcludePatterns,
'**/df-functions/*.md',
],
includeOrder: [
'index.md',
'getting-started/**',
'user-guide/**',
'enterprise/**',
'reference/**',
'faq-and-others/**',
'contributor-guide/**',
],
}],
versionNoindex,
robotsTxtGenerator,
faqSchema,
function injectLocaleSwitchScript() {
return {
name: 'inject-locale-switch-script',
injectHtmlTags() {
return {
headTags: [
{
tagName: 'script',
attributes: { src: '/js/locale-switch.js' }
}
]
};
}
};
}
],
themeConfig: {
// Replace with your project's social card
metadata: metaMap[locale],
navbar: {
logo: {
alt: 'Greptime logo',
src: 'img/logo-text.svg',
},
items: [
{
to: hostMap[locale],
position: 'left',
label: 'Home',
},
{to: hostMap[locale] + '/blogs/', label: 'Blogs', position: 'left'},
{
type: 'docsVersionDropdown',
position: 'right'
},
{
type: 'dropdown',
label: locale === 'en' ? 'English' : '中文',
position: 'right',
items: [
{
label: locale === 'en' ? 'English' : '中文',
to: '#',
className: 'dropdown__link',
},
{
label: locale === 'en' ? '中文' : 'English',
to: locale === 'en' ? 'https://docs.greptime.cn' : 'https://docs.greptime.com',
className: 'dropdown__link locale-switch-link',
},
],
},
{
href: 'https://github.com/GreptimeTeam/docs/',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
copyright: `©Copyright ${new Date().getFullYear()} Greptime Inc.`,
},
prism: {
theme: greptimePrismLightTheme,
darkTheme: greptimePrismDarkTheme,
additionalLanguages: ['java', 'toml'],
},
algolia: algoliaMap[locale]
} satisfies Preset.ThemeConfig,
};
export default config;