This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new 240c0e7ce99 fix: fix the 3.0/2.1 version docs edit this page link error (#1146) 240c0e7ce99 is described below commit 240c0e7ce99a2a080650e2c2e4f4427ef97155de Author: Jeffrey <color.d...@gmail.com> AuthorDate: Fri Sep 27 12:41:46 2024 +0900 fix: fix the 3.0/2.1 version docs edit this page link error (#1146)  --- src/constant/download.data.ts | 17 +++++++++++++++- src/theme/DocItem/Layout/pathTransfer.ts | 12 ++++++------ src/theme/DocSidebar/Desktop/Content/index.js | 28 ++++++++++++++++++++++++--- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/constant/download.data.ts b/src/constant/download.data.ts index 1ef2e0fa04c..95ed2a89466 100644 --- a/src/constant/download.data.ts +++ b/src/constant/download.data.ts @@ -1439,4 +1439,19 @@ export const RUN_ANYWHERE = [ description: 'Deploy Doris on AWS with CloudFormation templates', link: 'https://doris.apache.org/docs/install/cluster-deployment/doris-on-aws', }, -]; \ No newline at end of file +]; + + +export const DOWNLOAD_PDFS = [{ + version: '3.0', + filename: 'Apache Doris 中文手册 (v3.0).pdf', + link: 'https://cdn.selectdb.com/static/Apache_Doris_v3_0_4412376f6e.pdf' +}, { + version: '2.1', + filename: 'Apache Doris 中文手册 (v2.1).pdf', + link: 'https://cdn.selectdb.com/static/Apache_Doris_v2_1_c8bc030188.pdf' +}, { + version: '2.0', + filename: 'Apache Doris 中文手册 (v2.0).pdf', + link: 'https://cdn.selectdb.com/static/Apache_Doris_v2_0_0b89998444.pdf' +}]; \ No newline at end of file diff --git a/src/theme/DocItem/Layout/pathTransfer.ts b/src/theme/DocItem/Layout/pathTransfer.ts index 1fa92702098..9f558af0c03 100644 --- a/src/theme/DocItem/Layout/pathTransfer.ts +++ b/src/theme/DocItem/Layout/pathTransfer.ts @@ -4,8 +4,8 @@ const transformPathWithoutZhCN = (pathname: string): string => { return `${pathname.replace(/^\/docs\/(?:2\.1|2\.0|1\.2|dev)/, '').replace('/docs','').replace(/\/$/, '')}.md`; } else { const pathWithoutDocs = pathname.replace('/docs', ''); - if (pathname.includes('/2.1')) { - return `/versioned_docs/version-2.1${pathWithoutDocs.replace('/2.1', '')}.md`; + if (pathname.includes('/3.0')) { + return `/versioned_docs/version-2.1${pathWithoutDocs.replace('/3.0', '')}.md`; } else if (pathname.includes('/2.0')) { return `/versioned_docs/version-2.0${pathWithoutDocs.replace('/2.0', '')}.md`; } else if (pathname.includes('/1.2')) { @@ -13,7 +13,7 @@ const transformPathWithoutZhCN = (pathname: string): string => { } else if (pathname.includes('/dev')) { return `/docs${pathWithoutDocs.replace('/dev', '')}.md`; } else { - return `/versioned_docs/version-3.0${pathWithoutDocs}.md`; + return `/versioned_docs/version-2.1${pathWithoutDocs}.md`; } } }; @@ -30,8 +30,8 @@ const transformPathWithZhCN = (pathname: string): string => { } else if (pathname.includes('/releasenotes')) { return `/common_docs_zh/releasenotes/${pathname.replace(/^\/zh-CN\/docs(?:\/(?:2\.1|2\.0|1\.2|dev))?\/releasenotes\//,'')}.md`; } else if (pathname.includes('/docs')) { - if (pathname.includes('/2.1')) { - return `/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1${pathname.replace('/zh-CN/docs/2.1', '')}.md`; + if (pathname.includes('/3.0')) { + return `/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0${pathname.replace('/zh-CN/docs/3.0', '')}.md`; } else if (pathname.includes('/2.0')) { return `/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0${pathname.replace('/zh-CN/docs/2.0', '')}.md`; } else if (pathname.includes('/1.2')) { @@ -39,7 +39,7 @@ const transformPathWithZhCN = (pathname: string): string => { } else if (pathname.includes('/dev')) { return `/i18n/zh-CN/docusaurus-plugin-content-docs/current${pathname.replace('/zh-CN/docs/dev', '')}.md`; } else { - return `/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0${pathname.replace('/zh-CN/docs', '')}.md`;; + return `/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1${pathname.replace('/zh-CN/docs', '')}.md`;; } } else { return pathname; diff --git a/src/theme/DocSidebar/Desktop/Content/index.js b/src/theme/DocSidebar/Desktop/Content/index.js index 5bab7190870..dcc5cd4759f 100644 --- a/src/theme/DocSidebar/Desktop/Content/index.js +++ b/src/theme/DocSidebar/Desktop/Content/index.js @@ -8,6 +8,7 @@ import DownloadPdfActive from '@site/static/images/download-pdf-active.svg'; import DocSidebarItems from '@theme/DocSidebarItems'; import styles from './styles.module.css'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; +import { DOWNLOAD_PDFS } from '@site/src/constant/download.data'; // import { getLatestVersion } from '../../../../../docusaurus.config'; // import { useActivePluginAndVersion } from '@docusaurus/plugin-content-docs/client'; // import { useGlobalData } from '@docusaurus/useGlobalData'; @@ -26,6 +27,20 @@ function useShowAnnouncementBar() { return isActive && showAnnouncementBar; } +function downloadFile(url, filename) { + var xml = new XMLHttpRequest(); + xml.open('GET', url, true); + xml.responseType = 'blob'; + xml.onload = function () { + var url = window.URL.createObjectURL(xml.response); + var a = document.createElement('a'); + a.href = url; + a.download = filename; + a.click(); + }; + xml.send(); +} + export default function DocSidebarDesktopContent({ path, sidebar, className }) { const showAnnouncementBar = useShowAnnouncementBar(); const { siteConfig } = useDocusaurusContext() @@ -68,9 +83,16 @@ export default function DocSidebarDesktopContent({ path, sidebar, className }) { <ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}> {showVersion && <div className={styles.currentVersion}> {isEN ? 'Version:' : '当前版本:'} {currentVersion} - {/* <div onMouseLeave={() => setIshover(false)} onMouseEnter={() => setIshover(true)} className="cursor-pointer"> - {isHover ? <DownloadPdfActive /> : <DownloadPdf />} - </div> */} + { + ['3.0', '2.0', '2.1'].includes(currentVersion) && ( + <div onMouseLeave={() => setIshover(false)} onMouseEnter={() => setIshover(true)} className="cursor-pointer" onClick={() => { + const pdfInfo = DOWNLOAD_PDFS.find(item => item.version === currentVersion); + downloadFile(pdfInfo.link, pdfInfo.filename); + }}> + {isHover ? <DownloadPdfActive /> : <DownloadPdf />} + </div> + ) + } </div>} <DocSidebarItems items={sidebar} activePath={path} level={1} /> </ul> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org