This is an automated email from the ASF dual-hosted git repository. bhavanisudha pushed a commit to branch asf-site in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/asf-site by this push: new 729dac981de [HUDI-6972][DOCS] Fix config link redirection (#9908) 729dac981de is described below commit 729dac981deaca25e0c4fcce98eab18c0f6ac5d7 Author: Bhavani Sudha Saktheeswaran <2179254+bhasu...@users.noreply.github.com> AuthorDate: Mon Oct 23 12:32:37 2023 -0700 [HUDI-6972][DOCS] Fix config link redirection (#9908) --- website/src/theme/DocPage/index.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/website/src/theme/DocPage/index.js b/website/src/theme/DocPage/index.js index 552adcfa357..a8b5bf2ea36 100644 --- a/website/src/theme/DocPage/index.js +++ b/website/src/theme/DocPage/index.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -import React, {useState, useCallback} from 'react'; +import React, {useState, useCallback, useEffect} from 'react'; import {MDXProvider} from '@mdx-js/react'; import renderRoutes from '@docusaurus/renderRoutes'; import Layout from '@theme/Layout'; @@ -44,6 +44,27 @@ function DocPageContent({ setHiddenSidebarContainer((value) => !value); }, [hiddenSidebar]); + if(typeof window !== 'undefined') { + useEffect(() => { + const timeout = setTimeout(() => { + const [_, hashValue] = window.location.href.split('#'); + + const element = document.querySelectorAll(`[href="#${hashValue}"]`)?.[0]; + if(element) { + const headerOffset = 90; + const elementPosition = element.getBoundingClientRect().top; + const offsetPosition = elementPosition + window.pageYOffset - headerOffset; + window.scrollTo({ + top: offsetPosition + }); + } + }, 100); + + return () => { + clearTimeout(timeout); + } + }, [window.location.href]); + } return ( <Layout wrapperClassName={ThemeClassNames.wrapper.docsPages}