This is an automated email from the ASF dual-hosted git repository.

luzhijing 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 eea9f8d04590 [feat] update new features (#428)
eea9f8d04590 is described below

commit eea9f8d0459058fa52117daaa9b5310a81ce7874
Author: Jeffrey <[email protected]>
AuthorDate: Tue Mar 19 20:36:57 2024 +0800

    [feat] update new features (#428)
---
 docusaurus.config.js                        | 11 +++--
 src/theme/DocItem/Layout/index.tsx          | 72 +++++++++++++++++++++++++++++
 src/theme/DocItem/Layout/styles.module.css  | 10 ++++
 src/theme/DocItem/index.tsx                 | 21 +++++++++
 src/theme/DocItemFooter/index.d.ts          |  4 --
 src/theme/DocItemFooter/index.js            | 63 -------------------------
 src/theme/DocItemFooter/styles.module.css   | 11 -----
 src/theme/DocSidebarItem/Category/index.tsx | 10 ++--
 src/theme/EditThisPage/index.tsx            | 25 ++++++++++
 src/theme/Navbar/Content/index.tsx          |  1 -
 10 files changed, 139 insertions(+), 89 deletions(-)

diff --git a/docusaurus.config.js b/docusaurus.config.js
index 1cd4af329935..e76c83e346ad 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -175,11 +175,12 @@ const config = {
                     lastVersion: getLatestVersion(),
                     versions: getDocsVersions(),
                     sidebarPath: require.resolve('./sidebars.json'),
-                    editUrl: ({ locale, versionDocsDirPath, docPath }) => {
-                        if (versionDocsDirPath === 
'versioned_docs/version-dev') {
-                            return 
`https://github.com/apache/doris/edit/master/docs/${locale}/docs/${docPath}`;
-                        }
-                    },
+                    // editUrl: ({ locale, versionDocsDirPath, docPath }) => {
+                    //     return 
`https://github.com/apache/doris-website/edit/master/docs/${locale}/docs/${docPath}`;
+                    //     // if (versionDocsDirPath === 
'versioned_docs/version-dev') {
+                    //     //     return 
`https://github.com/apache/doris-website/edit/master/docs/${locale}/docs/${docPath}`;
+                    //     // }
+                    // },
                     showLastUpdateAuthor: false,
                     showLastUpdateTime: false,
                 },
diff --git a/src/theme/DocItem/Layout/index.tsx 
b/src/theme/DocItem/Layout/index.tsx
new file mode 100644
index 000000000000..b8bd18b76095
--- /dev/null
+++ b/src/theme/DocItem/Layout/index.tsx
@@ -0,0 +1,72 @@
+import React from 'react';
+import clsx from 'clsx';
+import { useWindowSize } from '@docusaurus/theme-common';
+import { useDoc } from '@docusaurus/theme-common/internal';
+import DocItemPaginator from '@theme/DocItem/Paginator';
+import DocVersionBanner from '@theme/DocVersionBanner';
+import DocVersionBadge from '@theme/DocVersionBadge';
+import DocItemFooter from '@theme/DocItem/Footer';
+import DocItemTOCMobile from '@theme/DocItem/TOC/Mobile';
+import DocItemTOCDesktop from '@theme/DocItem/TOC/Desktop';
+import DocItemContent from '@theme/DocItem/Content';
+import DocBreadcrumbs from '@theme/DocBreadcrumbs';
+import type { Props } from '@theme/DocItem/Layout';
+
+import styles from './styles.module.css';
+import EditThisPage from '../../EditThisPage';
+
+/**
+ * Decide if the toc should be rendered, on mobile or desktop viewports
+ */
+function useDocTOC() {
+    const { frontMatter, toc } = useDoc();
+    const windowSize = useWindowSize();
+
+    const hidden = frontMatter.hide_table_of_contents;
+    const canRender = !hidden && toc.length > 0;
+
+    const mobile = canRender ? <DocItemTOCMobile /> : undefined;
+
+    const desktop = canRender && (windowSize === 'desktop' || windowSize === 
'ssr') ? <DocItemTOCDesktop /> : undefined;
+
+    return {
+        hidden,
+        mobile,
+        desktop,
+    };
+}
+
+export default function DocItemLayout({ children }: Props): JSX.Element {
+    const docTOC = useDocTOC();
+    const { metadata } = useDoc();
+    const { editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, 
tags } = metadata;
+    return (
+        <div className="row">
+            <div className={clsx('col', !docTOC.hidden && styles.docItemCol)}>
+                <DocVersionBanner />
+                <div className={styles.docItemContainer}>
+                    <article>
+                        <DocBreadcrumbs />
+                        <DocVersionBadge />
+                        {docTOC.mobile}
+                        <DocItemContent>{children}</DocItemContent>
+                        <DocItemFooter />
+                    </article>
+                    <DocItemPaginator />
+                </div>
+            </div>
+            {docTOC.desktop && (
+                <div className="col col--3">
+                    {/* <div
+                        style={{
+                            paddingLeft: 20,
+                        }}
+                    >
+                        <EditThisPage editUrl={editUrl} />
+                    </div> */}
+                    {docTOC.desktop}
+                </div>
+            )}
+        </div>
+    );
+}
diff --git a/src/theme/DocItem/Layout/styles.module.css 
b/src/theme/DocItem/Layout/styles.module.css
new file mode 100644
index 000000000000..d5aaec1322c9
--- /dev/null
+++ b/src/theme/DocItem/Layout/styles.module.css
@@ -0,0 +1,10 @@
+.docItemContainer header + *,
+.docItemContainer article > *:first-child {
+  margin-top: 0;
+}
+
+@media (min-width: 997px) {
+  .docItemCol {
+    max-width: 75% !important;
+  }
+}
diff --git a/src/theme/DocItem/index.tsx b/src/theme/DocItem/index.tsx
new file mode 100644
index 000000000000..b7273a6b20d4
--- /dev/null
+++ b/src/theme/DocItem/index.tsx
@@ -0,0 +1,21 @@
+import React from 'react';
+import {HtmlClassNameProvider} from '@docusaurus/theme-common';
+import {DocProvider} from '@docusaurus/theme-common/internal';
+import DocItemMetadata from '@theme/DocItem/Metadata';
+import DocItemLayout from '@theme/DocItem/Layout';
+import type {Props} from '@theme/DocItem';
+
+export default function DocItem(props: Props): JSX.Element {
+  const docHtmlClassName = 
`docs-doc-id-${props.content.metadata.unversionedId}`;
+  const MDXComponent = props.content;
+  return (
+    <DocProvider content={props.content}>
+      <HtmlClassNameProvider className={docHtmlClassName}>
+        <DocItemMetadata />
+        <DocItemLayout>
+          <MDXComponent />
+        </DocItemLayout>
+      </HtmlClassNameProvider>
+    </DocProvider>
+  );
+}
diff --git a/src/theme/DocItemFooter/index.d.ts 
b/src/theme/DocItemFooter/index.d.ts
deleted file mode 100644
index 66898d4c4f86..000000000000
--- a/src/theme/DocItemFooter/index.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-/// <reference types="@docusaurus/plugin-content-docs" />
-/// <reference types="react" />
-import type { Props } from '@theme/DocItem';
-export default function DocItemFooter(props: Props): JSX.Element | null;
diff --git a/src/theme/DocItemFooter/index.js b/src/theme/DocItemFooter/index.js
deleted file mode 100644
index 94136957f508..000000000000
--- a/src/theme/DocItemFooter/index.js
+++ /dev/null
@@ -1,63 +0,0 @@
-import React from 'react';
-import clsx from 'clsx';
-import { ThemeClassNames } from '@docusaurus/theme-common';
-import LastUpdated from '@theme/LastUpdated';
-import EditThisPage from '@theme/EditThisPage';
-import TagsListInline from '@theme/TagsListInline';
-import styles from './styles.module.css';
-import Link from '@docusaurus/Link';
-import Translate from '@docusaurus/Translate';
-function TagsRow(props) {
-    return (
-        <div className={clsx(ThemeClassNames.docs.docFooterTagsRow, 'row 
margin-bottom--sm')}>
-            <div className="col">
-                <TagsListInline {...props} />
-            </div>
-        </div>
-    );
-}
-function EditMetaRow({ editUrl, lastUpdatedAt, lastUpdatedBy, 
formattedLastUpdatedAt }) {
-    return (
-        <div className={clsx(ThemeClassNames.docs.docFooterEditMetaRow, 
'row')}>
-            <div className="col">{editUrl && <EditThisPage editUrl={editUrl} 
/>}</div>
-            {/* <div className={clsx('col', styles.lastUpdated)}>
-        {(lastUpdatedAt || lastUpdatedBy) && (
-          <LastUpdated
-            lastUpdatedAt={lastUpdatedAt}
-            formattedLastUpdatedAt={formattedLastUpdatedAt}
-            lastUpdatedBy={lastUpdatedBy}
-          />
-        )}
-      </div> */}
-            <div className={clsx('col', styles.lastUpdated)}>
-                <Link to="https://github.com/apache/doris/discussions";>
-                    <Translate id="documentation.feedback">Feedback</Translate>
-                </Link>
-            </div>
-        </div>
-    );
-}
-export default function DocItemFooter(props) {
-    const { content: DocContent } = props;
-    const { metadata } = DocContent;
-    const { editUrl, lastUpdatedAt, formattedLastUpdatedAt, lastUpdatedBy, 
tags } = metadata;
-    const canDisplayTagsRow = tags.length > 0;
-    const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || 
lastUpdatedBy);
-    const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
-    if (!canDisplayFooter) {
-        return null;
-    }
-    return (
-        <footer className={clsx(ThemeClassNames.docs.docFooter, 
'docusaurus-mt-lg')}>
-            {canDisplayTagsRow && <TagsRow tags={tags} />}
-            {canDisplayEditMetaRow && (
-                <EditMetaRow
-                    editUrl={editUrl}
-                    lastUpdatedAt={lastUpdatedAt}
-                    lastUpdatedBy={lastUpdatedBy}
-                    formattedLastUpdatedAt={formattedLastUpdatedAt}
-                />
-            )}
-        </footer>
-    );
-}
diff --git a/src/theme/DocItemFooter/styles.module.css 
b/src/theme/DocItemFooter/styles.module.css
deleted file mode 100644
index 746af366c6f7..000000000000
--- a/src/theme/DocItemFooter/styles.module.css
+++ /dev/null
@@ -1,11 +0,0 @@
-.lastUpdated {
-  /* margin-top: 0.2rem; */
-  /* font-style: italic; */
-  /* font-size: smaller; */
-}
-
-@media (min-width: 997px) {
-  .lastUpdated {
-    text-align: right;
-  }
-}
diff --git a/src/theme/DocSidebarItem/Category/index.tsx 
b/src/theme/DocSidebarItem/Category/index.tsx
index 150cb04a57f6..26055aaaba63 100644
--- a/src/theme/DocSidebarItem/Category/index.tsx
+++ b/src/theme/DocSidebarItem/Category/index.tsx
@@ -89,11 +89,11 @@ export default function DocSidebarItemCategory({ item, 
onItemClick, activePath,
         setCollapsed(toCollapsed);
     };
     useAutoExpandActiveCategory({ isActive, collapsed, updateCollapsed });
-    useEffect(() => {
-        if (collapsible && expandedItem != null && expandedItem !== index && 
autoCollapseCategories) {
-            setCollapsed(true);
-        }
-    }, [collapsible, expandedItem, index, setCollapsed, 
autoCollapseCategories]);
+    // useEffect(() => {
+    //     if (collapsible && expandedItem != null && expandedItem !== index 
&& autoCollapseCategories) {
+    //         setCollapsed(true);
+    //     }
+    // }, [collapsible, expandedItem, index, setCollapsed, 
autoCollapseCategories]);
     return (
         <li
             className={clsx(
diff --git a/src/theme/EditThisPage/index.tsx b/src/theme/EditThisPage/index.tsx
new file mode 100644
index 000000000000..f4bee9485b41
--- /dev/null
+++ b/src/theme/EditThisPage/index.tsx
@@ -0,0 +1,25 @@
+import React from 'react';
+import Translate from '@docusaurus/Translate';
+import { ThemeClassNames } from '@docusaurus/theme-common';
+import IconEdit from '@theme/Icon/Edit';
+import type { Props } from '@theme/EditThisPage';
+
+export default function EditThisPage({ editUrl }: Props): JSX.Element {
+    return (
+        <a
+            href={editUrl}
+            target="_blank"
+            rel="noreferrer noopener"
+            className={ThemeClassNames.common.editThisPage}
+            style={{
+                display: 'flex',
+                alignItems: 'center',
+            }}
+        >
+            <IconEdit />
+            <Translate id="theme.common.editThisPage" description="The link 
label to edit the current page">
+                Edit this page
+            </Translate>
+        </a>
+    );
+}
diff --git a/src/theme/Navbar/Content/index.tsx 
b/src/theme/Navbar/Content/index.tsx
index 05af4ea7c833..d7be69c1bdab 100644
--- a/src/theme/Navbar/Content/index.tsx
+++ b/src/theme/Navbar/Content/index.tsx
@@ -144,7 +144,6 @@ export default function NavbarContent({ mobile }) {
                             <DocsVersionDropdownNavbarItem
                                 mobile={false}
                                 docsPluginId="default"
-                                collapsed={false}
                                 {...(getNavItem('docsVersionDropdown') as any)}
                             />
                         )}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to