diff --git a/docusaurus.config.js b/docusaurus.config.js index 9f11fb0..5a1a81f 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -97,6 +97,10 @@ module.exports = { type: 'custom-back-to-top', position: 'right' }, + { + type: 'custom-back-to-bottom', + position: 'right' + }, { type: 'custom-qa-button', position: 'right' diff --git a/src/components/BackToBottomNavbarItem.js b/src/components/BackToBottomNavbarItem.js new file mode 100644 index 0000000..75d6769 --- /dev/null +++ b/src/components/BackToBottomNavbarItem.js @@ -0,0 +1,39 @@ +import React from 'react'; +import BrowserOnly from '@docusaurus/BrowserOnly'; + +function BackToBottomButton() { + const handleBackToBottom = () => { + window.scrollTo({ + top: document.documentElement.scrollHeight, + behavior: 'smooth' + }); + }; + + return ( + + ); +} + +export default function BackToBottomNavbarItem() { + return ( + {() => } + ); +} \ No newline at end of file diff --git a/src/theme/NavbarItem/ComponentTypes.js b/src/theme/NavbarItem/ComponentTypes.js index 48d9ebe..2f87a74 100644 --- a/src/theme/NavbarItem/ComponentTypes.js +++ b/src/theme/NavbarItem/ComponentTypes.js @@ -9,6 +9,7 @@ import SearchNavbarItem from '@theme/NavbarItem/SearchNavbarItem'; import PdfExportNavbarItem from '../../components/PdfExportNavbarItem'; import PdfBackToTopNavbarItem from '../../components/PdfBackToTopNavbarItem'; +import BackToBottomNavbarItem from '../../components/BackToBottomNavbarItem'; import QAButtonNavbarItem from '../../components/QAButtonNavbarItem'; import TableOfContentsNavbarItem from '../../components/TableOfContentsNavbarItem'; @@ -23,6 +24,7 @@ const ComponentTypes = { docSidebar: DocSidebarNavbarItem, 'custom-pdf-export': PdfExportNavbarItem, 'custom-back-to-top': PdfBackToTopNavbarItem, + 'custom-back-to-bottom': BackToBottomNavbarItem, 'custom-qa-button': QAButtonNavbarItem, 'custom-table-of-contents': TableOfContentsNavbarItem, }; diff --git a/src/theme/NavbarItem/index.js b/src/theme/NavbarItem/index.js index 5684553..be35479 100644 --- a/src/theme/NavbarItem/index.js +++ b/src/theme/NavbarItem/index.js @@ -2,6 +2,7 @@ import React from 'react'; import NavbarItem from '@theme-original/NavbarItem'; import PdfExportNavbarItem from '../../components/PdfExportNavbarItem'; import PdfBackToTopNavbarItem from '../../components/PdfBackToTopNavbarItem'; +import BackToBottomNavbarItem from '../../components/BackToBottomNavbarItem'; import QAButtonNavbarItem from '../../components/QAButtonNavbarItem'; export default function NavbarItemWrapper(props) { @@ -11,6 +12,9 @@ export default function NavbarItemWrapper(props) { if (props.type === 'custom-back-to-top') { return ; } + if (props.type === 'custom-back-to-bottom') { + return ; + } if (props.type === 'custom-qa-button') { return ; }