Skip to content

Commit

Permalink
site: remove legacy code for hash jump (ant-design#44836)
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Sep 13, 2023
1 parent 10c78d3 commit 72da267
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions .dumi/theme/layouts/DocLayout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import { Helmet, useOutlet, useSiteData } from 'dumi';
import { Helmet, useOutlet } from 'dumi';
import React, { useContext, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
import zhCN from 'antd/es/locale/zh_CN';
import ConfigProvider from 'antd/es/config-provider';
Expand Down Expand Up @@ -30,11 +30,10 @@ const locales = {
const DocLayout: React.FC = () => {
const outlet = useOutlet();
const location = useLocation();
const { pathname, search, hash } = location;
const { pathname, search } = location;
const [locale, lang] = useLocale(locales);
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const { direction } = useContext(SiteContext);
const { loading } = useSiteData();

useLayoutEffect(() => {
if (lang === 'cn') {
Expand All @@ -53,20 +52,10 @@ const DocLayout: React.FC = () => {
}
}, []);

// handle hash change or visit page hash from Link component, and jump after async chunk loaded
useEffect(() => {
const id = hash.replace('#', '');

if (id) document.getElementById(decodeURIComponent(id))?.scrollIntoView();
}, [loading, hash]);

React.useEffect(() => {
if (typeof (window as any).ga !== 'undefined') {
(window as any).ga('send', 'pageview', pathname + search);
}
if (typeof (window as any)._hmt !== 'undefined') {
(window as any)._hmt.push(['_trackPageview', pathname + search]);
}
}, [location]);

const content = useMemo(() => {
Expand Down

0 comments on commit 72da267

Please sign in to comment.