Skip to content

Commit

Permalink
refactor: use history push for navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
charIeszhao committed Jan 15, 2025
1 parent 15b7900 commit 7e6b7ab
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Translate, { translate } from '@docusaurus/Translate';
import { type PropBlogPostMetadata } from '@docusaurus/plugin-content-blog';
import { type DocMetadata } from '@docusaurus/plugin-content-docs';
import { useHistory } from '@docusaurus/router';
import { clsx } from 'clsx';
import { useMemo, useRef, useState } from 'react';

Expand Down Expand Up @@ -48,6 +49,7 @@ const TitleWithSelectionDropdown = ({
onSelectSdk,
onSelectConnector,
}: Props) => {
const history = useHistory();
const slug = metadata.frontMatter.slug ?? '';
const sdkName = String(metadata.frontMatter.sdk ?? '');
const connectorName = String(metadata.frontMatter.connector ?? '');
Expand Down Expand Up @@ -111,8 +113,8 @@ const TitleWithSelectionDropdown = ({
selectedSlugPart +
slugLastPart
: slugFirstPart + selectedSlugPart + slug.slice(slug.indexOf(slugMiddlePart));
// eslint-disable-next-line @silverhand/fp/no-mutation
window.location.href = `/tutorial/${targetSlug}`;
// eslint-disable-next-line @silverhand/fp/no-mutating-methods
history.push(`/tutorial/${targetSlug}`);
}
};

Expand Down

0 comments on commit 7e6b7ab

Please sign in to comment.