Skip to content

Commit ba7e096

Browse files
authored
feat: enhance site-config (#2279)
1 parent 8c0e2cb commit ba7e096

File tree

4 files changed

+79
-62
lines changed

4 files changed

+79
-62
lines changed

docusaurus.config.ts

Lines changed: 17 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,22 @@
11
import { themes as prismThemes } from 'prism-react-renderer';
22
import type { Config } from '@docusaurus/types';
33
import type * as Preset from '@docusaurus/preset-classic';
4+
import { announcementBarContent, ASKBEND_URL, siteConfig, tagline } from './site-config';
5+
import siteRedirects from './site-redirects';
6+
47

58
const { site } = process.env;
69
const isCN = (site || "cn") === "cn";
710
const lang = isCN ? "zh" : "en";
811

9-
const homeLink = isCN ? "https://www.databend.cn" : "https://www.databend.com";
10-
const cloudLink = isCN ? "https://app.databend.cn" : "https://app.databend.com";
11-
const docsHomeLink = isCN
12-
? "https://docs.databend.cn"
13-
: "https://docs.databend.com";
14-
const TwitterSvg =
15-
'<svg width="20" style="top: 5px; position: relative" height="20" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg>';
16-
1712
const { site_env } = process.env;
1813
const isProduction = site_env === "production";
19-
const ASKBEND_URL = "https://ask.databend.com";
20-
const algolia = isCN
21-
? {
22-
appId: "FUCSAUXK2Q",
23-
apiKey: "0f200c10999f19584ec9e31b5caa9065",
24-
indexName: "databend",
25-
contextualSearch: true
26-
}
27-
: {
28-
appId: "XA8ZCKIEYU",
29-
apiKey: "81e5ee11f82ed1c5de63ef7ea0551abf",
30-
indexName: "databend",
31-
contextualSearch: false
32-
};
3314

3415
const config: Config = {
3516
title: "Databend",
3617
staticDirectories: ["static", "./docs/public"],
37-
tagline:
38-
"Databend - Your best alternative to Snowflake. Cost-effective and simple for massive-scale analytics.",
39-
url: docsHomeLink,
18+
tagline,
19+
url: siteConfig[lang].docsHomeLink, // Your website URL
4020
baseUrl: "/",
4121
onBrokenAnchors: "ignore",
4222
onBrokenLinks: "throw",
@@ -75,9 +55,9 @@ const config: Config = {
7555
],
7656
customFields: {
7757
isChina: isCN,
78-
docsHomeLink,
79-
homeLink,
80-
cloudLink,
58+
docsHomeLink: siteConfig[lang].docsHomeLink,
59+
homeLink: siteConfig[lang].homeLink,
60+
cloudLink: siteConfig[lang].cloudLink,
8161
blogTags: ["weekly", "databend"],
8262
askBendUrl: isProduction ? ASKBEND_URL : "",
8363
},
@@ -109,7 +89,7 @@ const config: Config = {
10989
// com: G-KYDJ7HV75X
11090
// cn: G-M88HSQF3DK
11191
// rs: G-WBQPTTG4ZG
112-
trackingID: isCN ? "G-M88HSQF3DK" : "G-KYDJ7HV75X",
92+
trackingID: siteConfig[lang].trackingID,
11393
anonymizeIP: true,
11494
},
11595
} satisfies Preset.Options,
@@ -209,32 +189,7 @@ const config: Config = {
209189
[
210190
'@docusaurus/plugin-client-redirects',
211191
{
212-
redirects: [
213-
{
214-
from: '/',
215-
to: '/guides/'
216-
},
217-
{
218-
from: '/sql/sql-reference/table-engines/iceberg',
219-
to: '/guides/access-data-lake/iceberg/'
220-
},
221-
{
222-
from: '/sql/sql-functions/ai-functions/ai-cosine-distance',
223-
to: '/sql/sql-functions/vector-distance-functions/vector-cosine-distance/'
224-
},
225-
{
226-
from: '/guides/migrate/',
227-
to: '/tutorials/migrate/'
228-
},
229-
{
230-
from: '/guides/migrate/mysql',
231-
to: '/tutorials/migrate/migrating-from-mysql-with-db-archiver'
232-
},
233-
{
234-
from: '/guides/migrate/snowflake',
235-
to: '/tutorials/migrate/migrating-from-snowflake'
236-
}
237-
],
192+
redirects: siteRedirects,
238193
createRedirects(existingPath) {
239194
if (existingPath?.includes('/developer/community/rfcs/')) {
240195
return existingPath.replace('/developer/community/rfcs/', '/guides/community/rfcs/');
@@ -252,18 +207,18 @@ const config: Config = {
252207
themeConfig: {
253208
// Replace with your project's social card
254209
image: "img/logo/logo-no-text.png",
255-
algolia,
210+
algolia: siteConfig[lang].algolia,
256211
mermaid: {
257212
theme: { dark: 'dark' }
258213
},
259214
announcementBar: {
260215
id: "announcementBar-2", // Increment on change
261-
content: `⭐️ If you like Databend, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://github.com/datafuselabs/databend">GitHub</a> and follow us on <a target="_blank" rel="noopener noreferrer" href="https://x.com/DatabendLabs" >Twitter</a> ${TwitterSvg}`,
216+
content: announcementBarContent,
262217
},
263218
navbar: {
264219
title: "DOCUMENTATION",
265220
logo: {
266-
href: homeLink,
221+
href: siteConfig[lang].homeLink,
267222
target: "_blank",
268223
srcDark: "img/logo-dark.svg",
269224
src: "img/logo.svg",
@@ -330,15 +285,15 @@ const config: Config = {
330285
},
331286
{
332287
label: "Downloads",
333-
to: `${homeLink}/download/`,
288+
to: `${siteConfig[lang].homeLink}/download/`,
334289
},
335290
{
336291
label: "Developer",
337292
to: "/developer/",
338293
},
339294
{
340295
label: "Blog",
341-
to: `${homeLink}/blog/`,
296+
to: `${siteConfig[lang].homeLink}/blog/`,
342297
},
343298
],
344299
},
@@ -350,13 +305,13 @@ const config: Config = {
350305
href: "https://link.databend.com/join-slack",
351306
},
352307
{
353-
label: "Twitter",
308+
label: "X",
354309
href: "https://x.com/DatabendLabs",
355310
},
356311
],
357312
},
358313
],
359-
copyright: `Copyright © 2023 Datafuse Labs, Inc. Built with Docusaurus. <br><br> <img src="https://www.datocms-assets.com/31049/1618983297-powered-by-vercel.svg">`,
314+
copyright: '@DatabendLabs',
360315
},
361316
prism: {
362317
theme: prismThemes.github,

site-config.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import XSvg from './static/icons/x';
2+
export const siteConfig = {
3+
zh: {
4+
homeLink: 'https://www.databend.cn',
5+
cloudLink: 'https://app.databend.cn',
6+
docsHomeLink: 'https://docs.databend.cn',
7+
algolia: {
8+
appId: "FUCSAUXK2Q",
9+
apiKey: "0f200c10999f19584ec9e31b5caa9065",
10+
indexName: "databend",
11+
contextualSearch: true
12+
},
13+
trackingID: "G-M88HSQF3DK"
14+
},
15+
en: {
16+
homeLink: 'https://www.databend.com',
17+
cloudLink: 'https://app.databend.com',
18+
docsHomeLink: 'https://docs.databend.com',
19+
algolia: {
20+
appId: "XA8ZCKIEYU",
21+
apiKey: "81e5ee11f82ed1c5de63ef7ea0551abf",
22+
indexName: "databend",
23+
contextualSearch: false
24+
},
25+
trackingID: "G-KYDJ7HV75X"
26+
}
27+
}
28+
29+
export const ASKBEND_URL = "https://ask.databend.com";
30+
31+
export const tagline = "Databend - Your best alternative to Snowflake. Cost-effective and simple for massive-scale analytics."
32+
33+
export const announcementBarContent = `⭐️ If you like Databend, give it a star on <a target="_blank" rel="noopener noreferrer" href="https://github.com/databendlabs/databend">GitHub</a> and follow us on <a target="_blank" rel="noopener noreferrer" href="https://x.com/DatabendLabs" >X(Twitter)</a> ${XSvg}`

site-redirects.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const siteRedirects = [
2+
{
3+
from: '/',
4+
to: '/guides/'
5+
},
6+
{
7+
from: '/sql/sql-reference/table-engines/iceberg',
8+
to: '/guides/access-data-lake/iceberg/'
9+
},
10+
{
11+
from: '/sql/sql-functions/ai-functions/ai-cosine-distance',
12+
to: '/sql/sql-functions/vector-distance-functions/vector-cosine-distance/'
13+
},
14+
{
15+
from: '/guides/migrate/',
16+
to: '/tutorials/migrate/'
17+
},
18+
{
19+
from: '/guides/migrate/mysql',
20+
to: '/tutorials/migrate/migrating-from-mysql-with-db-archiver'
21+
},
22+
{
23+
from: '/guides/migrate/snowflake',
24+
to: '/tutorials/migrate/migrating-from-snowflake'
25+
}
26+
];
27+
export default siteRedirects;

static/icons/x.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const x = `<svg width="20" style="top: 5px; position: relative" height="20" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg>`;
2+
export default x;

0 commit comments

Comments
 (0)