Skip to content

Commit bf48468

Browse files
authored
refactor: redirect download to official website (#3074)
1 parent a215674 commit bf48468

2 files changed

Lines changed: 17 additions & 444 deletions

File tree

src/pages/download/index.tsx

Lines changed: 17 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -1,215 +1,19 @@
1-
// Copyright 2023 Datafuse Labs.
2-
import React, { FC, ReactElement } from "react";
3-
import Layout from "@theme/Layout";
4-
import clsx from "clsx";
5-
import ReactMarkdown from "react-markdown";
6-
import remarkGfm from "remark-gfm";
7-
import { timeFormatAgo } from "@site/src/utils/tools";
8-
import styles from "./styles.module.scss";
9-
import useGetReleases from "@site/src/hooks/useGetReleases";
10-
import Card from "@site/src/components/BaseComponents/Card";
11-
import Tag from "@site/src/components/BaseComponents/Tag";
12-
import Linux from "@site/static/icons/linux.svg";
13-
import Ubuntu from "@site/static/icons/ubuntu.svg";
14-
import Apple from "@site/static/icons/apple.svg";
15-
import Microsoft from "@site/static/icons/microsoft.svg";
16-
import { IAssets } from "@site/src/types/download";
17-
import DatabendTable from "@site/src/components/DatabendTable";
1+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
2+
import { useMount } from "ahooks";
3+
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
184

19-
const Releases: FC = (): ReactElement => {
20-
const { releasesList, name: releaseName, bendsqlRecource } = useGetReleases();
21-
const { filterBody, assets: latestAssets, published_at } = releasesList[0];
22-
const { name: bendsqlTagName } = bendsqlRecource;
23-
function Icons({
24-
isApple,
25-
isUbuntu,
26-
isWindows,
27-
}: {
28-
isApple: boolean | undefined;
29-
size?: number;
30-
isUbuntu: boolean | undefined;
31-
isWindows?: boolean | undefined;
32-
}): ReactElement {
33-
return (
34-
<>
35-
{isWindows ? (
36-
<Microsoft />
37-
) : (
38-
<>
39-
{isApple ? (
40-
<Apple />
41-
) : (
42-
<>{isUbuntu ? <Ubuntu></Ubuntu> : <Linux />}</>
43-
)}
44-
</>
45-
)}
46-
</>
47-
);
48-
}
49-
const buriedPointForDownload = (asset: IAssets) => {
50-
const {
51-
name,
52-
osType,
53-
osTypeDesc,
54-
id,
55-
browser_download_url,
56-
created_at,
57-
size,
58-
isApple,
59-
isUbuntu,
60-
tag_name,
61-
} = asset;
62-
// @ts-ignore
63-
if (window?.gtag) {
64-
// @ts-ignore
65-
window.gtag("event", "click", {
66-
event_category: "DownloadPackages",
67-
event_label: tag_name + "_" + osTypeDesc,
68-
package_download_info: JSON.stringify({
69-
name,
70-
osType,
71-
osTypeDesc,
72-
id,
73-
browser_download_url,
74-
created_at,
75-
size,
76-
isApple,
77-
isUbuntu,
78-
tag_name,
79-
}),
80-
});
5+
function Download() {
6+
const {
7+
siteConfig: {
8+
customFields: { homeLink },
9+
},
10+
} = useDocusaurusContext() as any;
11+
useMount(() => {
12+
if (ExecutionEnvironment?.canUseDOM) {
13+
window.location.href = `${homeLink}/download/`;
8114
}
82-
};
83-
return (
84-
<Layout
85-
title={`Databend - Activate your Object Storage for real-time analytics`}
86-
description={`A modern Elasticity and Performance Cloud Data Warehouse, activate your Object Storage(S3, Azure Blob, or MinIO) for real-time analytics`}
87-
>
88-
<div className={styles.part}>
89-
<div className={styles.download}>Download Databend</div>
90-
<div className={styles.latest}>Latest Version: {releaseName}</div>
91-
<Card className={styles.latestBlock}>
92-
<div className={styles.latestVersion}>
93-
<div className={styles.topTag}>
94-
<span className={styles.version}>{releaseName}</span>
95-
<Tag>Latest</Tag>
96-
</div>
97-
<div className={styles.updateTime}>
98-
Released {timeFormatAgo(published_at)}. For earlier versions,
99-
please refer to{" "}
100-
<a
101-
target="_blank"
102-
href="https://github.com/databendlabs/databend/releases"
103-
>
104-
GitHub
105-
</a>
106-
.
107-
</div>
108-
<div className={styles.nowAssets}>
109-
{latestAssets?.map((asset, index) => {
110-
const {
111-
isApple,
112-
browser_download_url,
113-
osTypeDesc,
114-
formatSize,
115-
isUbuntu,
116-
} = asset;
117-
return (
118-
<Card
119-
onClick={() => buriedPointForDownload(asset)}
120-
href={browser_download_url}
121-
isDownload
122-
key={index}
123-
className={clsx(
124-
styles.nowItem,
125-
!isApple && styles.nowItemLinux,
126-
isUbuntu && styles.nowItemLinuxUbuntu
127-
)}
128-
padding={[8, 16]}
129-
>
130-
<Icons isApple={isApple} isUbuntu={isUbuntu}></Icons>
131-
<div className={styles.right}>
132-
<div>{osTypeDesc}</div>
133-
<div>Size: {formatSize}</div>
134-
</div>
135-
</Card>
136-
);
137-
})}
138-
</div>
139-
</div>
140-
<div className={clsx(styles.submitRecord)}>
141-
<ReactMarkdown remarkPlugins={[remarkGfm]}>
142-
{filterBody}
143-
</ReactMarkdown>
144-
</div>
145-
</Card>
146-
</div>
147-
<div className={clsx(styles.part, styles.part2)}>
148-
<div className={styles.download}>Download BendSQL</div>
149-
<div className={styles.latest}>Latest Version: {bendsqlTagName}</div>
150-
<Card className={styles.latestBlock}>
151-
<div className={styles.latestVersion}>
152-
<div className={styles.topTag}>
153-
<span className={styles.version}>{bendsqlTagName}</span>
154-
<Tag>Latest</Tag>
155-
</div>
156-
<div className={styles.updateTime}>
157-
Released {timeFormatAgo(bendsqlRecource?.published_at)}. For
158-
earlier versions, please refer to{" "}
159-
<a
160-
target="_blank"
161-
href="https://github.com/databendlabs/bendsql/releases"
162-
>
163-
GitHub
164-
</a>
165-
.
166-
</div>
167-
<div className={styles.nowAssets}>
168-
{bendsqlRecource?.assets?.map((asset: any, index: number) => {
169-
const {
170-
isApple,
171-
browser_download_url,
172-
osTypeDesc,
173-
formatSize,
174-
isUbuntu,
175-
isWindows,
176-
} = asset;
177-
return (
178-
<Card
179-
onClick={() => buriedPointForDownload(asset)}
180-
href={browser_download_url}
181-
isDownload
182-
key={index}
183-
className={clsx(
184-
styles.nowItem,
185-
!isApple && styles.nowItemLinux,
186-
isUbuntu && styles.nowItemLinuxUbuntu,
187-
isWindows && styles.nowItemWindows
188-
)}
189-
padding={[8, 16]}
190-
>
191-
<Icons
192-
isApple={isApple}
193-
isUbuntu={isUbuntu}
194-
isWindows={isWindows}
195-
></Icons>
196-
<div className={styles.right}>
197-
<div>{osTypeDesc}</div>
198-
<div>Size: {formatSize}</div>
199-
</div>
200-
</Card>
201-
);
202-
})}
203-
</div>
204-
</div>
205-
<div className={styles.submitRecord}>
206-
<ReactMarkdown remarkPlugins={[remarkGfm]}>
207-
{bendsqlRecource?.filterBody}
208-
</ReactMarkdown>
209-
</div>
210-
</Card>
211-
</div>
212-
</Layout>
213-
);
214-
};
215-
export default Releases;
15+
});
16+
return null;
17+
}
18+
19+
export default Download;

0 commit comments

Comments
 (0)